This snippet of code uses the .filter() function within jQuery to find all “li” elements that contain just the text “findthis”.

$('li:contains("findthis")').filter(function() {
  return $(this).text() == "findthis";
}).addClass('active');
Comments are closed.