Monday, December 2, 2013

Check if a var available in jQuery

This functions returns value 1 if var has some value and 0 when var is not present

jQuery.fn.exists = function(){return this.length>0;}

if ($(selector).exists()) {
    // Do something
}

No comments:

Post a Comment