Yes, this is annoying to me as well.
The workaround is to use the .size() method.
if ( $('nonexistent').size() > 0)
or you could just shortcut it to
if ($('nonexistent').size())
--
Brandon Aaron
On 1/25/07, Jan Vorisek <[EMAIL PROTECTED]> wrote:
> So far I tried revision 1172 and it does not fix the issue.
>
> What is the clean approach to test if any object is found?
> if( $('nonexistent')[0] )?
> if( $('nonexistent').length>0)?
> if( $('nonexistent').get(0))?
>
> Jan.
>
> >> But after upgrading to 1.1.1, I got an error saying focus() wasn't a
> >> method. So I added a little debugging alert, and apparently,
> >> $(".focus").get(0) is returning the document object! If I call
> >> $(".focus").size() it returns 0, but yet when I call .get(0) it's
> >> returning something? Anyone else seeing this?
> >>
>
> Yes: http://jquery.com/dev/bugs/bug/861/
>
>
> -- Klaus
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/