JSFiddle - React, Tailwind, and code Playground

by Vladymyr Shevchuk

HTML

<button id="btn">Click me!</button>

JavaScript

class A {
	constructor (el) {
  	this.el = el;
  	this.initEventListeners(this.el);
  }
  
  initEventListeners () {
  	this.el.addEventListener('click', () => this.showEventObj())
  }
  
  removeEventListeners () {
  	// this.el.removeEventListener('click', ...)
  }
  
  showEventObj () {
  	console.log('current element', this.el);
  }
}

const obj = new A(btn);
/* obj.removeEventListeners(); */