$('#id').size !== 0 would not work. I'll bet that your actual code has
.size() instead of .size without the parentheses, right? The size property
is a method, so the !== 0 test would always return true (since a function
reference is never equal to 0).
 
.length is slightly more efficient than .size() - look at the source code
for the .size method:
 
    size: function() {
        return this.length;
    }
 
The only reason the size method exists at all is for compatibility with very
old jQuery code that may have used it back in the days when there was no
.length property.
 
-Mike



  _____  

From: Alexey Blinov

Personally I do it with `$('#id').size !== 0` but length is goood to i think
:)


On Dec 24, 2007 5:55 PM, Cloudream <[EMAIL PROTECTED]> wrote: 



$('#id').length>0 ?


On Dec 24, 10:11pm, debussy007 < [EMAIL PROTECTED]> wrote:
>
> what is the best way in jquery to check wether an id exists ?

Reply via email to