JSFiddle - React, Tailwind, and code Playground
by adeneo
HTML
<div id="title">click</div>
JavaScript
var $ = function(selector, context) {
if (this instanceof $) {
this[0] = document.querySelector(selector),
this.context = context || document
return this;
}else{
return new $(selector, context);
}
}
$.prototype.click = function(callback) {
var element = this[0]; // we still need [0] to get the element
element.addEventListener('click', callback.bind(element), false);
return this;
}
$('#title').click(function() {
console.log(this); // it's now the native DOM node, not our "jQuery" object
});