JSFiddle - React, Tailwind, and code Playground
HTML
<div id="someEl">Bound to Cat</div>
<div id="someEl2">Bound to nothin'</div>
CSS
#someEl, #someEl2 {
width: 100px;
height: 100px;
border: 1px solid #000;
}
JavaScript
function Cat() {
this.name = 'Gordon';
this.element = $('#someEl');
this.element.click((function() {
console.log(this.name); // logs Gordon
}).bind(this));
}
function Dog() {
this.name = 'Gordon';
this.element = $('#someEl2');
this.element.click(function() {
console.log(this.name); // logs ???
});
}
var cat = new Cat();
var dog = new Dog();