JSFiddle - React, Tailwind, and code Playground
by rishul matta
HTML
<div>
<div id = "test">
hi
</div>
</div>
JavaScript
var e = document.getElementById("test");
alert(e.innerText);
e.addEventListener('click',function () {
alert("i was clicked");
});
//this section adds code for cross browser compatibility
//event handler code added on window object to make the events compatible with mozilla and IE
if (document.addEventListener) { //mozilla standard
this.addEvent = function (elem, type, fn) {
elem.addEventListener(type, fn, false);
return fn;
};
}
else
if (document.attachEvent) { //ie standard
this.addEvent = function (elem, type, fn) {
var bound = function () {
return fn.apply(elem, arguments);
};
elem.attachEvent("on" + type, bound);
return bound;
};
}