JSFiddle - React, Tailwind, and code Playground
HTML
<ul><li><button class="testButton">Test button</button></li></ul>
JavaScript
function OnButtonDown (button) {
alert("The class work")
}
function Init () {
var className = "testButton";
var button = false;
var buttons = document.getElementsByClassName(className);
for (var i=0; i<buttons.length; i++) {
button = buttons[i];
if (button.addEventListener) { // all browsers except IE before version 9
button.addEventListener ("mousedown", function () {
OnButtonDown (button)
}, false);
button.addEventListener ("mouseup", function () {
OnButtonUp (button)
}, false);
}
else {
if (button.attachEvent) { // IE before version 9
button.attachEvent ("onmousedown", function () {
OnButtonDown (button)
});
button.attachEvent ("onmouseup", function () {
OnButtonUp (button)
});
}
}
}
}
Init();