I'm looking into the code of the jQuery ToolTip plugin(hereinafter Tooltip), and have a noticed a behaviour I don't fully understand.
Tooltip binds a mouseover function like so:
.mouseover(save)
When called in this way, this
variable is HtmlDivElement
.
I tried changing the mouseover
to this:
.mouseover(function(e){save(event)})
Since I'm looking for the MouseEvent. However, now this
variable is Window
.
I found a way to baypass this and get the HtmlDivElement
by using this line of code:
.mouseover(function(e){save(this, event)})
and using this
as a replacment for the this
inside the function.
My question is - why is the save
function losing it's scope when being called inside an anonymous function inside the mouseover binding?