gpt4 book ai didi

Jquery 向上滚动悬停停止

转载 作者:行者123 更新时间:2023-11-28 02:00:54 24 4
gpt4 key购买 nike

快速提问。

尝试为我的网站制作一个可悬停的滚动控件。当您将鼠标悬停在按钮上而不是单击它时,我希望页面滚动。我让它大部分时间都在工作,但它似乎有点小故障,主要是因为悬停事件不断触发动画方法。我想知道是否有更干净的方式来触发它。下面是我到目前为止的代码。

    $("#goUp").hover(function () { 
var curpos= $('body').scrollTop();
$("body").animate({scrollTop: curpos- 200}, 800);
}, function () {
// I want to stop the animation here when they mouse out
});

$("#goDown").hover(function () {
var curpos= $('body').scrollTop();
$("body").animate({scrollTop: curpos+ 200}, 800);
}, function () {
// I want to stop the animation here when they mouse out
});

感谢您的帮助

最佳答案

使用以下命令停止动画。

$("body").stop()

关于Jquery 向上滚动悬停停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13992763/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com