jQuery hover鼠标不停经过时它就不停触发,500毫秒内不触发,悬停时间超过500毫秒才会触发hover事件

2025-02-21 23:43:37
推荐回答(1个)
回答1:

var timer;
$("a").on({
"mouseenter":function(){
clearTimeout(timer);
timer=setTimeout(function(){
//这里触发hover事件
},500);
},
"mouseleave":function(){
clearTimeout(timer);
}
});