On Oct 31, 12:21 pm, Matt <[EMAIL PROTECTED]> wrote:
> This should be an easy one but it's been a long day...
>
> Let's say I have this structure:
>
> <div id="container">
>   <span class="on">1</span>
>   <span class="off">2</span>
>   <span class="on">3</span>
> </div>
>
> Basically, I have a function that I only want to run when all three of
> the <spans> are set to 'on'. Since this is dynamic code, there might
> be more than 3 spans etc, so I need something robust. Any simple one-
> liners to test if all <spans> within #container have a class of 'on'?
>

$$('#container span').length === $$('#container span.on').length

// or a bit more effecient

$$('#container span').all(function(el){ return
el.hasClassName('on') });

> Thanks
> Matt

--
kangax
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to