Skip to content

Instantly share code, notes, and snippets.

@talbergs
Created August 4, 2016 18:37
Show Gist options
  • Save talbergs/765c1fc3b5af0d61e7ef2bf37a84578b to your computer and use it in GitHub Desktop.
Save talbergs/765c1fc3b5af0d61e7ef2bf37a84578b to your computer and use it in GitHub Desktop.
jQuery.prototype.$cache = function(xpath, name) {
if (xpath.forEach) {
xpath.forEach(function(xp){
this.$cache(xp);
}.bind(this));
} else {
!name && (name = xpath.substr(1));
this[name] = this.find(xpath)
}
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment