Created
February 14, 2017 22:27
-
-
Save jasonwaters/fe9848d37c612288e5e97b4118a748f6 to your computer and use it in GitHub Desktop.
jayquery chaining
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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