[jQuery] Re: search list in a div for attribute value

2009-08-29 Thread Peter Edwards
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'}); } }); });

[jQuery] Re: search list in a div for attribute value

2009-08-28 Thread tatlar
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

[jQuery] Re: search list in a div for attribute value

2009-08-28 Thread tatlar
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

[jQuery] Re: search list in a div for attribute value

2009-08-28 Thread tatlar
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