Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Gorpetrosov/a0df8b65bdafc88a2d3edd2268e827b2 to your computer and use it in GitHub Desktop.
Save Gorpetrosov/a0df8b65bdafc88a2d3edd2268e827b2 to your computer and use it in GitHub Desktop.
A simple jquery code to search a text inside of li tag
//searchText is a input type text
$('#searchText').bind('keyup', function() {
var searchString = $(this).val();
$("ul li").each(function(index, value) {
currentName = $(value).text()
if( currentName.toUpperCase().indexOf(searchString.toUpperCase()) > -1) {
$(value).show();
} else {
$(value).hide();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment