I saw this code snippet:
$("ul li").text().search(new RegExp("sometext", "i"));
and wanted to know if this can be extended to any string?
I want to accomplish the following, but it dosen’t work:
$("li").attr("title").search(new RegExp("sometext", "i"));
Also, anyone have a link to the jQuery documentation for this function? I fail at googling apparently.
search()is a String method.You are executing the
attrfunction on every<li>element.You need to invoke
eachand use thethisreference within.Example: