I am using following code but it returns following error
Uncaught TypeError: Object [object HTMLAnchorElement] has no method 'userInput'
Here is the code jsfiddle
var ClickEvent = function (event) {
this.ev = $('.' + event);
this.ev.on('click', function () { this.userInput(); });
};
ClickEvent.prototype = function () {
return {
userInput: function () {
console.log('user');
},
show: function () {
console.log('show');
}
};
}();
var c = new ClickEvent('event');
I am calling userInput
function inside on()
callback function but it returns above error
.
How can I solve this problem?
console.log(this)
inside the click event handler function (where you now have userInput). What does it tell you ? :) – Benjamin Gruenbaum yesterday$
jQuery? If it is, add the tag. – epascarello yesterday