On Wed, May 13, 2009 at 3:34 PM, louis w <[email protected]> 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
[email protected]
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---