JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<button id="testBtn">Test</button>
</body>
JavaScript
function TestUIElem() {
this.elem = null;
}
TestUIElem.prototype = {
activate: function () {
this.elem = document.querySelector('button#testBtn');
this.elem.addEventListener('click', this, false);
},
click: function () {
alert('test');
this.deactivate();
},
deactivate: function () {
this.elem.removeEventListener('click', this);
},
handleEvent: function(event){
switch(event.type){
case 'click':
this.click(event);
break;
}
}
};
testUIElem = new TestUIElem();
testUIElem.activate();