I am using the following jQuery
var etag = \'kate\'
if (etag.length > 0) {
$(\'div\').each(function () {
$(this).find(\'ul:not(:contains(\' +
This filter checks if any of the words in the given string match the text of the element.
jQuery.expr[':'].containsAny = function(element, index, match) {
var words = match[3].split(/\s+/);
var text = $(element).text();
var results = $.map(words, function(word) {
return text === word;
});
return $.inArray(true, results) !== -1;
};
Show and hide as:
$('ul').hide();
$('li:containsAny(john kate)').parents('ul').show();
See an example here.