Last active
March 3, 2021 07:44
-
-
Save im-noob/6165cb11eb76eec48f34d2db26d1d445 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let certificate_search_ele = $('#certificate-search'); | |
let certificate_list_text_ele = $('.certificate-list-text'); | |
let certificate_category_ele = $('#certificate_category'); | |
function applyFilters() { | |
/*Search Filter */ | |
let value = certificate_search_ele.val().toLowerCase(); | |
certificate_list_text_ele.filter(function () { | |
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) | |
}); | |
/*Drop Down Filter*/ | |
let selected_category = certificate_category_ele.val(); | |
certificate_list_text_ele.each(function(key,value){ | |
if (selected_category !== 'all') { | |
if (!($(value).attr('certificate_category_id') === selected_category)) { | |
$(value).hide(); | |
} | |
} | |
}); | |
} | |
$(document.body).on('keyup', '#certificate-search' ,function(){ | |
applyFilters(); | |
}); | |
certificate_category_ele.on('change', function () { | |
applyFilters(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment