search()
is a String method.
You are executing the attr
function on every <li>
element.
You need to invoke each
and use the this
reference within.
Example:
$('li').each(function() {
var isFound = $(this).attr('title').search(/string/i);
//do something based on isFound...
});