How to check null objects in jQuery

Check the jQuery FAQ

You can use the length property of the jQuery collection returned by your selector:

if ( $('#myDiv').length ){}

Leave a Comment