Skip to content

Instantly share code, notes, and snippets.

@veltman
Created March 13, 2014 22:58
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 veltman/9538964 to your computer and use it in GitHub Desktop.
Save veltman/9538964 to your computer and use it in GitHub Desktop.
jQuery caching
//Return a cached selection if it's been used,
//Otherwise get the jQuery selection and cache it
var $$ = function(x) {
if (!this[x]) this[x] = $(x);
return this[x];
}
$$("div.test").html("a");
$$("div.test").html("b");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment