Link 到另一个 html 文件中的另一个 div

Link to another div in another html file

我想将访问者引导至另一个 html 文件中的特定 div, 这就是它在同一个 html: <a href="#goTo"></a> 中的方式,但如果 div 在另一个 html 中,它就不起作用。例如 <a href="../index.html #goTo">This link should go to the div goTo in the index file </a>

删除 link 中的 space:

<a href="../index.html#goTo">This link should go to the div goTo in the index file</a>

尝试直接在文件名后写锚点,不要 space:

<a href="../index.html#goTo">This link should go to the div goTo in the index file </a>

如果这不起作用,请检查锚点是否真的命名为 "goTo"。

您正在使用的东西叫做 anchor

示例:

<a href="#goTo">Go there</a>
[more html]
<h2 id="goTo">My GoTo Header</h2>

您还可以在其他网站上定位锚点,例如:

<a href="otherSite.html#goTo">Go there</a>