我正在使用jQuery mouseenter和mouseleave事件向下滑动div .
一切都运行良好,除了mouseleave,如果鼠标移动div非常慢,似乎不会发射 . 如果我以相对正常或快速的速度移动鼠标,那么它按预期工作 .
任何人都可以解释这个或提供有关如何解决这个问题的任何信息?
码:
$(document).ready(function() {
$('header').mouseenter(function() {
$(this).stop().animate({'top' : '25px'}, 500, function() {
$(this).delay(600).animate({'top' : '-50px'}, 500);
});
}).mouseleave(function(e) {
var position = $(this).position();
if (e.pageY > position.top + $(this).height()) {
$(this).stop().delay(600).animate({'top' : '-75px'}, 500) ;
}
});
});
1 回答
尝试使用悬停代替mouseenter和mouseleave;