On Wed, May 13, 2009 at 3:34 PM, louis w <louiswa...@gmail.com> wrote:

>
> I have an array containing a number of strings. I would like to
> continue exucuting my script only if an item has ANY/ALL of the
> strings assigned as a class name.
>
> $A(['foo', 'bar', 'foob']);
>
> Is there an elegant want to do this without having to loop through the
> items?


Supposing you have the aforementioned element stored in the - elm -
variable, and the classes' array in the - classesArr - variable:

var classNamesRegex = new RegExp('\\b(' + classesArr.join('|') + ')\\b'); //
Generates /\b(foo|bar|foob)\b/

if(!classNamesRegex.test(elm.className)){
   window.alert('get me out of here');
}

Gabriel Gilini

www.usosim.com.br
gabr...@usosim.com.br

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to