Skip to content

Instantly share code, notes, and snippets.

@alanmarcos
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanmarcos/511a1223b12e126a73bb to your computer and use it in GitHub Desktop.
Save alanmarcos/511a1223b12e126a73bb to your computer and use it in GitHub Desktop.
jquery .exists(), to check if an element exists in the dom
;(function ($) {
$.fn.exists = function () {
return this.length > 0? true : false
};
}(jQuery));
@alanmarcos
Copy link
Author

Usage:
$('#element').exists();
returns a boolean

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment