比如我有这个
<a style="text-decoration:none;" href="#section2">Hello World</a>
当我将 url 提供给另一个人时,例如 example.com/test.html#section2
他们访问了它 我希望浏览器稍微显示或关注
Hello World 是 a href
链接的内容
最佳答案
指定当您访问该链接时您希望看到的元素的“id”:
<a href="#section2">Go to Section 2</a>
<div>
<h1 id="section2">Section 2</h1>
</div>
关于javascript - 我如何制作 anchor 链接 # 当直接访问 url 时它会聚焦在浏览器上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71014262/