jQuery Time 鼠标悬停在元素上(悬停) [英] jQuery Time mouse is over element (Hover)

查看:32
本文介绍了jQuery Time 鼠标悬停在元素上(悬停)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在几个链接上附加了一个悬停事件,当你越过它时会出现一个框.

i have a hover event attached to a few links and when you go over it a box appears.

有没有一种方法可以让悬停事件仅在鼠标悬停在链接上超过 500 毫秒时触发?因此,目前只要鼠标移过链接,框就会出现,但我希望它仅在鼠标悬停在框上 500 毫秒或更长时间时才会出现.

Is there a way that i can make the hover event only trigger if the mouse has been over the link for more then 500 ms? So currently as soon as the mouse goes over the link the box appears but i want it to only appear if the mouse has been over the box for 500 ms or longer.

推荐答案

var myTimeout;
$('#mylink').mouseenter(function() {
    myTimeout = setTimeout(function() {
        //do stuff
    }, 500);
}).mouseleave(function() {
    clearTimeout(myTimeout);
});

这篇关于jQuery Time 鼠标悬停在元素上(悬停)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆