繁体   English   中英

检测鼠标是否不在iframe中的元素上

[英]Detect if the mouse is not over an element in an iframe

我希望能够检测鼠标是否在某个div上。 所以我这样做

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

如何检测鼠标是否不在div上? 我也读到,如果元素是iframe,这可能不起作用。 有没有办法在iframe中也能完成这项工作?

使用hover()和类似的标志

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM