Skip to content

Instantly share code, notes, and snippets.

@jasonwaters
Created February 14, 2017 22:27
Show Gist options
  • Save jasonwaters/fe9848d37c612288e5e97b4118a748f6 to your computer and use it in GitHub Desktop.
Save jasonwaters/fe9848d37c612288e5e97b4118a748f6 to your computer and use it in GitHub Desktop.
jayquery chaining
function jayquery(selector) {
const elements = document.querySelectorAll(selector);
return {
bgcolor: function(value) {
elements.forEach(element => element.style.background = value);
return this;
},
text: function(value) {
elements.forEach(element => element.innerText = value);
return this;
}
};
}
jayquery('.something').bgcolor('orange').text('hello');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment