Skip to content

Instantly share code, notes, and snippets.

@ephbaum
Created April 9, 2014 14:37
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 ephbaum/10277870 to your computer and use it in GitHub Desktop.
Save ephbaum/10277870 to your computer and use it in GitHub Desktop.
jQuery.exists Extension
/* Extend jQuery slightly to determine existence of element */
jQuery.fn.exists = function() {
return this.length > 0;
}
/* How to implement... */
if ($(selector).exists()) {
// Do something
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment