I wrote a Object which “manages” a <div>-Element. I wanted it to do something on mousemove so I wrote this line in a function I call to create the content of this -Element:
$('#' + this.slider_id).mousemove(this.mouseMoveHandler(e));
Later i defined a function which handles this Event:
this.mouseMoveHandler = function (e) {
var mouseX = e.pageX;
....
}
But when I call it, all I get is :
Uncaught ReferenceError: e is not defined
What am I missing?
As Rob mentioned… you’re actually invoking your function, with some unknown variable
e. You should be passing a reference to the function itself, which will then get invoked when the event happens, passing along the event object.So to fix all that, just do this: