我有一个 JS 可以用这个从页面底部平滑滚动到顶部,它可以工作:
<script>
$("a[href='#top']").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return true;
});
</script>
Run Code Online (Sandbox Code Playgroud)
但是现在我想从顶部到底部平滑滚动,我尝试了这个:
<script>
$("a[href='#footer']").click(function() {
$("html, body").animate({ scrollToBottom: 0 }, "slow");
return true;
});
</script>`
Run Code Online (Sandbox Code Playgroud)
它不起作用,它不是一个平滑的滚动。有谁知道这有什么问题?