What about if ($('#warningmsg').length > 0) highlightWarningMsg();

This is how I do it - is the array reference faster than checking length? If
so, I'll switch!


Sam Collett wrote:
> 
> On 19/01/07, Peter Bengtsson <[EMAIL PROTECTED]> wrote:
>> Currently my code looks something like this:
>>
>> if ($('#warningmsg').size()) highlightWarningMsg();
>>
>> Is that the "correct" way of testing if a jQuery object contains
>> anything?
>>
>>
>> --
>> Peter Bengtsson,
>> work www.fry-it.com
>> home www.peterbe.com
>> hobby www.issuetrackerproduct.com
> 
> You could also do:
> 
> if ($('#warningmsg')[0])
> 
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/.size%28%29-to-test-if-something-exists-tf3040462.html#a8454297
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to