gpt4 book ai didi

jQuery 函数等于 href=#

转载 作者:行者123 更新时间:2023-12-01 02:36:58 26 4
gpt4 key购买 nike

是否有一个jquery函数可以让你转到#name,就像你链接到href="#name"一样,这样我就可以在文档准备好后直接转到#name

最佳答案

您只需更改 location.hash,如下所示:

$(function() {
window.location.hash = '#name'; //works with or without the # included
});

尽管如果您只是超链接到该页面,这是内置的浏览器行为,例如访问 http://site.com/page.html#name 将具有相同的滚动效果 -负载效果。

关于jQuery 函数等于 href=#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4126455/

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