Skip to content

Instantly share code, notes, and snippets.

@wibawasuyadnya
Created September 26, 2022 08:43
Show Gist options
  • Save wibawasuyadnya/abefa23e6201d16fdcbbca94bed2fa2e to your computer and use it in GitHub Desktop.
Save wibawasuyadnya/abefa23e6201d16fdcbbca94bed2fa2e to your computer and use it in GitHub Desktop.
//in page search filter with callback if no result found//
jQuery(document).ready(function($){
var $search = $("#inpsearch-bar").on('input',function(){
var matcher = new RegExp($(this).val(), 'gi');
$('.filter-box').show().not(function(){
return matcher.test($(this).find('.name').text())
}).hide();
if($('.filter-box:visible').length===0){
$('.noresult').show();
} else {
$('.noresult').hide();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment