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.onClick.bind(this), false);
};
TestUIElem.prototype.onClick = function () {
alert('test');
this.deactivate();
};
TestUIElem.prototype.deactivate = function () {
this.elem.removeEventListener('click', this.onClick.bind(this));
};
testUIElem = new TestUIElem();
testUIElem.activate();