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

查看:116
本文介绍了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天全站免登陆