Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extend jquery with function to check if an element exists
//extend jquery with function to check if element exists
$.fn.exists = function(){
return this.length > 0 ? this : false;
}
//usage
$('.matchme').exists(); //returns reference to element if exists otherwise false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.