Thursday, December 8, 2011

jQuery: How to test if a given jQuery selector exists in DOM

jQuery does not throw an error if you query an unexisting DOM selector, but JavaScript will complain if you try to apply jQuery methods to this element. This is how to check if a given variable matches a DOM node:

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.