Skip to content

Instantly share code, notes, and snippets.

@accidentallyc
Last active August 29, 2015 14:25
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 accidentallyc/427ff433cab001fe6d6d to your computer and use it in GitHub Desktop.
Save accidentallyc/427ff433cab001fe6d6d to your computer and use it in GitHub Desktop.
REQUIRE a dom to be retrieved via jQuery. Useful for keeping projects in tact specially when changes keep happening.
/* Assumes that jQuery has been loaded */
window.$REQUIRE = function(s){
var e = jQuery.apply(this,arguments);
if( e.length ) return e;
else throw "DOM " + s + " is required but cannot be found";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment