JSFiddle - React, Tailwind, and code Playground
by Alex83
HTML
<div class="wrapper">dfk</div>
JavaScript
window.onload = function() {
function $(selector)
{
var prefix = selector[0];
selector = selector.substring(1);
switch(prefix){
case '#': return document.getElementById(selector);
case '.': return document.getElementsByClassName(selector);
default: return document.getElementsByTagName(prefix + selector);
}
}
var x = $('.wrapper');
for( i = 0; i < x.length; i++ ) {
x[i].onclick = function() {
alert('Hello world!');
}
}
}