A slightly different approach - try the following:
var etag='kate test blah'; var tags = etag.split(' '); $('div ul').each(function () { var list = $(this); list.hide(); list.children('li').each(function() { var item = $(this); if ($.inArray(item.html(), tags) >= 0) list.show(); }); });
It is written in the browser, so I'm sorry if there are any errors!
- change -
Actually, I re-read the question, and this code will not work. You need to first determine the behavior: should the list contain all the tags or only one of the tags that will be shown?
- change 2 -
Code updated. The view is inefficient, but it must do the job.
source share