Determining whether jQuery doesn't find any element

Posted by Bardock on Stack Overflow See other posts from Stack Overflow or by Bardock
Published on 2010-05-20T20:44:30Z Indexed on 2010/05/20 20:50 UTC
Read the original article Hit count: 145

Filed under:
|

Hi,

I'm using jQuery's selectors, especially id selector:

$("#elementId")...

How should I determine whether jQuery has found the element or not? Even If the element with the specified id doesn't exist the next statement give me: [object Object]

alert($("#idThatDoesnotexist"));

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about selectors