Becky
Becky

Reputation: 5585

Detect if the mouse is not over an element in an iframe

I want to be able to detect if the mouse is over a certain div. So I do this

if ($('#mydv').is(':hover')) {
    //doSometing
});

how do I detect if the mouse in not over the div? Also I read that this might not work if the element is an iframe. Is there a way to make this work in an iframe as well?

Upvotes: 0

Views: 430

Answers (1)

AmmarCSE
AmmarCSE

Reputation: 30587

Use hover() and flags like

var isOver = false;
$('#mydv').hover(function() {
    isOver = true;
}, function() {
    isOver = false;
});
. 
.
.
//elsewhere in your code you can use isOver to know whether the cursor is over or not

Upvotes: 3

Related Questions