Try this - it may work for you:
$(function(){
var srch = [ "foo", "bar" ] ;
// make a Regex from the search terms
var attr_regex = '('+srch.join('|')+')';
$('#gallery li').each(function(){
if ($(this).attr("title").match(attr_regex)) {
$(this).css({background:'#f00'});
}
});
});
Oops. This sentence:
"I want to traverse the array, looking at the title attribute, and if
it is in the array $search I want the style changed. "
Should be:
"I want to traverse the list, looking at the title attribute, and if
it is in the array $search I want the style changed."
And this:
var $t
Hmm. Would this be expected to work?
$gallery.find('li[title='+$title_to_searchl+']').css('color','red');
On Aug 28, 1:31 pm, tatlar wrote:
> Oops. This sentence:
> "I want to traverse the array, looking at the title attribute, and if
> it is in the array $search I want the style changed. "
> S
Oops. This sentence:
"I want to traverse the array, looking at the title attribute, and if
it is in the array $search I want the style changed. "
Should be:
"I want to traverse the list, looking at the title attribute, and if
it is in the array $search I want the style changed."
On Aug 28, 1:2
4 matches
Mail list logo