我只想让这件事成功一次。现在,我的滚动头总是工作的,所以不可能向下滚动我的页面。
$(function() {
$(".showhover").hover(
function() {
$('div.mouseover').show(),
$("html, body").animate({scrollTop: $('div.mouseover').innerHeight() });
});
}); 发布于 2013-11-20 14:50:38
您可以使用one(),但是hover()是jQuery中的一个自定义函数,它将鼠标和鼠标放在一起,执行one('hover')将附加到hover事件,这是不建议的。
在使用mouseenter / mouseleave时,您必须自己恢复功能:
$(function() {
$(".showhover").one({
mouseenter: function() {
$('div.mouseover').show(),
$("html, body").animate({scrollTop: $('div.mouseover').innerHeight() });
},
mouseleave: function() {
$('div.mouseover').hide(),
}
});
}); 发布于 2013-11-20 14:49:58
试试one('mouseenter mouseleave',悬停是鼠标和鼠标保存组合的伪事件。
$(".showhover").one('mouseenter mouseleave', function(e) {
$('div.mouseover').toggle();
if(e.type === 'mouseenter')
$("html, body").animate({scrollTop: $('div.mouseover').innerHeight() });
});https://stackoverflow.com/questions/20099034
复制相似问题