Created
July 22, 2014 18:19
-
-
Save dennysfredericci/ca99b08648649b545dfd to your computer and use it in GitHub Desktop.
A simple jquery code to search a text inside of li tag
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
//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(); | |
} | |
}); | |
}); |
Thanks for the code and it works well. but we need to add var keyword in front of currentName variable.
var currentName = $(value).text()
thanks for this
thanks
Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for sharing 👍