如何转到试剂中的特定位置(按ID)?

问题描述 投票:0回答:1

我在http://example.com/bar中有一个div标签,其ID为foo1。我在http://example.com/foo中有一个锚标记,如下所示:[:a {:href "http://example.com/bar#foo1"}],因为我想跳到锚定网页中具有foo1 id的div。但是,这样做并不会使我进入该div,而只是显示了默认情况下到达页面顶部的行为。我在做什么错?

html anchor clojurescript reagent
1个回答
0
投票

锚点(a元素)可以具有name属性,该属性用于URL片段(例如,转到文档中的命名锚点)。参见https://www.w3schools.com/tags/att_a_name.asp

如果您希望将HTML元素ID用作锚点,也许您想要类似https://github.com/bryanbraun/anchorjs的东西>

© www.soinside.com 2019 - 2024. All rights reserved.