【发布时间】:2013-07-31 08:12:16
【问题描述】:
当 mouseenter 在每个项目上时,其覆盖消失,当 mouseleave - 覆盖显示。
当我有更多项目,并且 快速 随机悬停在它们上时,它们不会返回到之前的状态。这很烦人:/
为什么会这样?
$('.item').mouseenter(function () {
var $this = $(this);
setTimeout(function () {
$this.find('.item-overlay').css('z-index', '-1');
}, 300);
}).mouseleave(function () {
$(this).find('.item-overlay').css('z-index', '1');
});
【问题讨论】:
-
创建一个小提琴或将您的代码发送给我们,因为用这么少的信息很难帮助您。
-
似乎计时器可以解决您的问题。例如当输入一个项目时,从大约 500 毫秒开始 tiemout 并在其完成后执行悬停功能。这种方式将排除快速悬停。
-
没有代码很难,问题也可能是离开处理程序不会正确触发
-
更新了 jsfiddle 的链接
标签: jquery hover mouseenter mouseleave