I have following situation. In a constructor of a pseudo class I attach a click event to an element. When the event is triggered I would like to refer from the callback function to the object where the event was set.
Code of the pseudo class constructor
function MyClass(){
this.myClassAttribute = "A class attribute";
// here `this` refers to the object
$("span").click(function(){
// here `this` refer to a matched element, i.e. "span"
// How to get the value of `myClassAttribute`?
});
}
How to refer to the object without an global variable?