Using JavaScript filter method is the quickest way to filter and search the text in the ul > li or any element you want to in your page html.
Just provide the id # of the element and define your text in search_text variable.
You can also get this text using jQuery from any element of the page, another variable or input field on the page, we are using hard code text for simplicity.
//make sure you use opening and closing script tag before adding this js code jQuery(document).ready(function(){ var search_text = "Li Label"; jQuery( "#menu li" ) .filter( function () { return jQuery( this ).text().toLowerCase().indexOf( search_text.toLowerCase() ) }) .first().addClass("active"); // Returns and adds the active Class to first element that matches the text</div><pre> });
Hope that helps.