-
-
Save kinddeveloper/dc9bb4611bd25c4dc716adb1e9ae6af8 to your computer and use it in GitHub Desktop.
Filter Example: All Social site(Facebook, Linkedin, VK etc ) filter way...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var countries = []; | |
var methods = []; | |
$(document).ready(function(){ | |
function filter (){ | |
$(".wm-courses-popular-wrap").parent().hide(); | |
$(".wm-courses-popular-wrap").toArray().forEach((item) => { | |
const hasCountry = countries.length > 0 ? countries.indexOf($(item).attr('country')) > -1 : true; | |
const hasMethod = methods.length > 0 ? methods.indexOf($(item).attr('method')) > -1 : true; | |
if (hasCountry && hasMethod) { | |
$(item).parent().css('display', 'list-item'); | |
} | |
}) | |
} | |
$("#country li input").click(function(){ | |
var id = $(this).attr('id'); | |
if(id == "type1"){ | |
if($("#"+id).is(":checked")){ | |
for(var i=2; i<=197; i++){ | |
$("#type"+i).prop('checked', true); | |
countries.push($("#type"+i).attr('id')); | |
} | |
} | |
else { | |
for(var i=2; i<=197; i++){ | |
$("#type"+i).prop('checked', false); | |
} | |
countries = []; | |
} | |
} | |
else { | |
$("#type1").prop('checked', false); | |
if($("#"+id).is(":checked")){ | |
countries.push(id); | |
} | |
else { | |
countries.splice( countries.indexOf(id), 1 ); | |
} | |
} | |
filter() | |
}); | |
$("#method li input").click(function(){ | |
var id = $(this).attr('id'); | |
if(id == "method1"){ | |
if($("#"+id).is(":checked")){ | |
for(var i=2; i<=6; i++){ | |
$("#method"+i).prop('checked', true); | |
methods.push($("#method"+i).attr('id')); | |
} | |
} | |
else { | |
for(var i=2; i<=6; i++){ | |
$("#method"+i).prop('checked', false); | |
methods = []; | |
} | |
} | |
} | |
else { | |
$("#method1").prop('checked', false); | |
if($("#"+id).is(":checked")){ | |
methods.push(id); | |
} | |
else { | |
methods.splice( methods.indexOf(id), 1 ); | |
} | |
} | |
filter() | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment