<div id="menu">
<div>foo</div>
<div>bar</div>
</div>
Is it possible to access the this
that refers to thing
rather than the this
that refers to the div that was clicked on, inside the event handler method handleClick
?
Note: I need to access both this
s inside handleClick
$(document).ready(function() {
var thing = {
menu: $("#menu"),
init: function() {
var _this = this;
this.doSomething();
this.menu.on("click", "div", this.handleClick);
},
doSomething: function() {
console.log(this); // thing
},
handleClick: function() {
console.log(this); // div that was clicked on
// How to console.log(_this) i.e. thing ?
}
};
thing.init();
});