gpt4 book ai didi

javascript - 平滑滚动没有 anchor 只有 jQuery

转载 作者:行者123 更新时间:2023-11-30 12:56:23 24 4
gpt4 key购买 nike

我有一个允许我水平滚动的 jQuery 脚本,但它是一个生锈的旧滚动条,我想在不更改整个代码的情况下使其平滑。

我想用 .animate 更改 this.scrollLeft -= (delta * 90); 但我是 jQuery 的初学者。

到目前为止,这是我的代码:

$(document).ready(function() {

$('html, body, eall, *').mousewheel(function(e, delta) {
this.scrollLeft -= (delta * 90);
e.preventDefault();
});
});

最佳答案

你可以这样做:

$('html, body').animate({
scrollLeft : 0 // or whatever value you need here
}, 750);

关于javascript - 平滑滚动没有 anchor 只有 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18960615/

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