I saw this code snippet:
$(\"ul li\").text().search(new RegExp(\"sometext\", \"i\"));
and wanted to know if this can be extended to any str
search() is a String method.
search()
You are executing the attr function on every element. You need to invoke each and use the this reference within.
attr
each
this
Example:
$('li').each(function() { var isFound = $(this).attr('title').search(/string/i); //do something based on isFound... });