如何检查鼠标是否位于jQuery中的一个元素之上?在jQuery中,是否有一种我缺少的快速简单的方法来做到这一点?我不想使用mouseover事件,因为我已经将它用于其他事情。我只需要知道鼠标是否在给定时刻超过了一个元素。如果有一个“IsMouseOver”函数,我想这样做:function hideTip(oi) {
setTimeout(function() { if (!IsMouseOver(oi)) $(oi).fadeOut(); }, 100);}
3 回答

函数式编程
TA贡献1807条经验 获得超9个赞

狐的传说
TA贡献1804条经验 获得超3个赞
$("someelement").mouseenter(function(){ clearTimeout($(this).data('timeoutId')); $(this).find(".tooltip").fadeIn("slow");}).mouseleave(function(){ var someElement = $(this), timeoutId = setTimeout(function(){ someElement.find(".tooltip").fadeOut("slow"); }, 650); //set the timeoutId, allowing us to clear this trigger if the mouse comes back over someElement.data('timeoutId', timeoutId); });

qq_花开花谢_0
TA贡献1835条经验 获得超7个赞
if ($('#element:hover').length != 0) { // do something ;)}
- 3 回答
- 0 关注
- 1434 浏览
添加回答
举报
0/150
提交
取消