Using jQuery to find elements that contain a specific text string

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');