gpt4 book ai didi

Javascript使页面跳转到特定位置

转载 作者:可可西里 更新时间:2023-11-01 01:21:46 25 4
gpt4 key购买 nike

我在javascript中有一种方法可以让页面跳转到页面的特定位置,比如

<span id='jump_to_this_location'></span>

我不想重新加载页面,

最佳答案

2020 年答案

一个简单而现代的方法是这样的:

document.getElementById("jump_to_this_location").scrollIntoView({behavior: 'smooth'});

behaviour: 'smooth' 参数使跳跃......好吧......平滑。这可能是你们大多数人想要的。

关于Javascript使页面跳转到特定位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3569329/

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