JSFiddle - React, Tailwind, and code Playground
HTML
<div id="test">Click Me</div>
CSS
#test{
border: 1px solid;
padding: 10px;
display: inline-block;
cursor: pointer;
}
Babel + JSX
const makeObj = function() {
this.logMe = () => {
// just in case the method is ran more than once we remove any click handler previously attached
$("#test").off("click");
// now attach the click handler to the element.
$("#test").click(()=>{
console.log("hello!!");
});
}
};
const myObj = new makeObj();
myObj.logMe();
myObj.logMe();
myObj.logMe();