开发者

Jquery javascript: have a filtering list(works), need help keeping all LI's visible when there's no matches

http://jsfiddle.net/nicktheandroid/ape5U/34/

Type hol into the textbox on the fiddle example. you'll see that all the LI's have the class hidden, making them hidden. now开发者_运维技巧 if you make what you had in the textbox into the word holy, you'll see that you all the sudden have 3 matches.

I need it to show all LI's(categories) if there's no matches, instead of hiding all of them, ive been trying to figure this out for hours and cannot, when I change one thing it breaks another. grr.


Add a condition at the end of your if (length > 2) statement, so you have:

if (length > 2) {   
   ...
   if(count == 0) $('.filtered li').removeClass("hidden"); //Add this line!
}else{
  ...
}
...

I tested and works ok. Hope this helps. Cheers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜