Accessing class member variables inside an event handler in Javascript
问题 I have a quick question regarding the proper way to access Javascript class member variables from inside of an event handler that class uses. For example: function Map() { this.x = 0; this.y = 0; $("body").mousemove( function(event) { this.x = event.pageX; // Is not able to access Map's member variable "x" this.y = event.pageY; // Is not able to access Map's member variable "y" }); } Rather than changing the member variable of the "Map" class, the "this.x" in the event handler tries to affect