There's a couple of issue with the code that needs to be addressed. First and foremost:
$("#myList li").filter(function() {
$("#myList li").show();
For every li element, you're making a call to show all li elements. This means that if you have 3 elements and the first two do not contain the text you're searching for, the third element will still tell the page to show them. What you probably need to do is either remove the
show()
line altogether, or move it outside of the
filter()
function as so:
$("#myList li").show();
$("#myList li").filter(function() {
Another point is you probably don't want to use the
filter()
function but instead use
each()[
^] as you're not actually doing anything with the resulting object.