On Thu, Dec 17, 2009 at 7:32 AM, Joe Grossberg
<joegrossberg....@gmail.com>wrote:

> Instead, I do it like this (since zero is false-y in JavaScript):
>
> if ( $('.foo').length ) {
>  alert('at least one matching element');
> } else {
>  alert('nothing matches');
> }
>
> But is that the preferred way of doing this?
>

As far as I am aware, yes... checking the length property is the way that
I've seen it done.

-- 
Charlie Griefer
http://charlie.griefer.com/

I have failed as much as I have succeeded. But I love my life. I love my
wife. And I wish you my kind of success.

Reply via email to