$$ always returns an array, although sometimes that array is empty.  
The safest thing is to loop over that array with each() or another  
iterator, as those can deal with empty arrays quite logically by not  
doing anything.

If you want to test that $$ found one or more items, look at the  
length property of the returned array:

var found = $$('.foo');
if(found.length > 0){
        //do something here
}

Walter

On Jul 14, 2009, at 7:30 AM, Lox wrote:

>
> Hello,
>
> How can I test $$ as found the element I search for?
>
> if( $$('.Overlay') ) this.Overlay = $$('.Overlay'); doesn't do the
> trick...
>
> Regards
> >


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