Created
April 27, 2015 13:17
-
-
Save bjdixon/af44af12d95ee9ea0aaf to your computer and use it in GitHub Desktop.
Extend jquery with function to check if an element exists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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