Reputation: 15
$('window').mouseenter(function(){
mouseover = true;
}).mouseleave(function(){
mouseover = false;
});
In the code above, would 'window' be correct syntax? If not, what would be the correct way to create a Boolean that tracks when the mouse in on the window and then off the window.
Upvotes: 1
Views: 36
Reputation: 4137
In Javascript window
is an object, so your code will be
var mouseover;
$(window).mouseenter(function(){
mouseover = true;
}).mouseleave(function(){
mouseover = false;
});
Upvotes: 0
Reputation: 10633
Following is correct syntax
$(window).mouseenter(function(){
mouseover = true;
}).mouseleave(function(){
mouseover = false;
});
$('window')
will try to look for a tag named window, not the window object.
Upvotes: 1