javascript - jQuery Mobile Search Hide Search Options -
i want none of search things shown until typed in. made class hidden , used .show() when item searched up, not working.
demo: http://jsfiddle.net/dyyfb/207/
js:
$("#search").keyup(function(){ var searchword = this.value; $("#list li").each(function(){ if($(this). find("h3, p"). text().touppercase(). indexof(searchword.touppercase()) >=0) $(this).show(); else $(this).hide(); }); });
here might looking jsfiddle example
i kinda added code didn't format well. can change .slideup()
, .slidedown()
. them better.
$('#list li').hide(0); //hide elements $("#search").keyup(function(){ var searchword = $.trim(this.value); if(searchword === ""){ //checks if search term nothing , starts on $('#list li').slideup(150); return false; } $("#list li").each(function(){ if($(this). find("h3, p"). text().touppercase(). indexof(searchword.touppercase()) >=0) $(this).slidedown(150); else $(this).slideup(150); });
});
Comments
Post a Comment