JSFiddle - React, Tailwind, and code Playground
HTML
<div class="test">Test</div>
<div class="test2">One more</div>
CSS
.newClass {
color: red
}
JavaScript
var $ = function(selectors) {
return document.querySelectorAll(selectors);
}
Node.prototype.addClass = function (param) {
var myNodeList = this;
this.className = this.className + " " + param;
return this;
}
NodeList.prototype.each = function (callback) {
var myNodeList = this;
for (var i = 0; i < myNodeList.length; i++) {
console.log(myNodeList[i] instanceof Node);
callback.call(myNodeList[i]);
}
return this;
}
console.log($(".test").each(function () {
this.addClass('newClass')
}));