Reputation: 2443
Do you know how to check whether the mouse is over an element?
Somethnig like this?
setTimeout(function() {
if($(this).mouseover()) { // this not work
return false;
} else {
$(this).hide();
}
}, 1000);
Thanks.
Upvotes: 0
Views: 329
Reputation: 111870
I'm assuming you're operating within a closure where 'this' represents a single element:
var mouseovered = false,
myElem = this;
$(myElem)
.mouseover(function(){
mouseovered = true;
})
.mouseout(function(){
mouseovered = false;
});
setTimeout(function() {
if(mouseovered) {
return false;
} else {
$(myElem).hide();
}
}, 1000);
Notice that I'm using "myElem" instead of the "this" keyword, which, in the context of the setTimeout callback will be a reference to the Window object - obviously not what you want.
Upvotes: 1
Reputation: 104168
You could use something like this:
var isMouseOver = false;
$(myitem).hover(function() {isMouseOver = true;},
function() {isMouseOver = false;});
Upvotes: 2
Reputation: 18870
Use the onmouseover event on the element in question to call a function to hide the element in question (as this seems to be what you want to do).
Upvotes: 0