1)我们有一个index.html带有块的页面:
<body>
<div id="action1">One</div>
<div id="action2">Two</div>
<div id="action3">Three</div>
</body>
2) CSS
body div { color: blue; }
body div.current { font-weight: bold; color: red; }
3)其他带有链接index.html和一些目标的页面:
<a href="index.html#action1">Link to One</a><br/>
<a href="index.html#action2">Link to Two</a><br/>
<a href="index.html#action3">Link to Three</a><br/>
问题是如何捕获页面上的当前链接目标index.html并为目标块提供额外的类。
如果打开页面的当前链接是index.html#action1,那么添加类.current到<div id="action1">One</div>- 将变为<div id="action1" class="current">One</div>
如果index.html#action2-><div id="action2" class="current">Two</div>
等等。
- 查看 #
target - 查看
id - if
target=idaddClass("current") 用于块id
谢谢。