jQuery filter function is not showing exact match :(
function callme(filterData){ $("ul.treeview").find("li").hide(); if(filterData.indexOf("|")!=-1){ var filterData = filterData.split("|"); for(i=0;i<filterData.length;i++){ jQuery("ul.treeview").find("li").filter(function(index) { return jQuery.trim($(this).text()) == filterData.trim(); }).show(); } }else{ jQuery("ul.treeview").find("li").filter(function(index) { return jQuery.trim($(this).text()) == filterData.trim(); }).show(); } }
here is my html...
<ul id="leftNavigation" class="treeview"> <li> <ul> <li > <a href="#">Application</a><font class="leftNavHitsFont"> - (3)<开发者_StackOverflow中文版/font> </li> </ul> <ul> <li > <a href="#">Application Notes</a><font class="leftNavHitsFont"> - (1)</font> </li> </ul> </li> </ul>
Yeah, that is the definition of something containing something else.
Maybe you meant to get an exact match?
jQuery("ul.treeview").find("li").filter(function(index) {
return jQuery.trim($(this).text()) == jQuery.trim(filterData);
}).show();
jsFiddle example
精彩评论