誰能幫我...我想根據我的網址活動鏈接基於URL
這裏我的菜單上添加一個活動類的代碼是
<div class="taglist">
<a class="automotive" title="Automotive Tag" href="#">Automotive</a>
<a class="banca" title="Banca Tag" href="#">Banca</a>
<a class="banking-pt" title="Banking Tag" href="#">Banking</a>
<a class="big-data" title="Big Data Tag" href="#">Big Data</a>
<a class="bigdata" title="BigData Tag" href="#">BigData</a>
<a class="cloud" title="Cloud Tag" href="#">Cloud</a>
</div>
可能URL's
http://www.whatever.com/?tag=automotive,big-data,cloud
http://www.whatever.com/?tag=automotive,big-data
http://www.whatever.com/tag/automotive
所以,我需要的是當網址是http://www.whatever.com/?tag=automotive,big-data我想添加一個類,如活動。
例子:
URL: http://www.whatever.com/?tag=automotive,big-data
HTML:
<div class="taglist">
<a class="automotive active" title="Automotive Tag" href="#">Automotive</a>
<a class="banca" title="Banca Tag" href="#">Banca</a>
<a class="banking-pt" title="Banking Tag" href="#">Banking</a>
<a class="big-data active" title="Big Data Tag" href="#">Big Data</a>
<a class="bigdata" title="BigData Tag" href="#">BigData</a>
<a class="cloud" title="Cloud Tag" href="#">Cloud</a>
</div>
[jQuery的主動類菜單項基於當前URL](可能重複http://stackoverflow.com/questions/10593591/jquery -active-class-to-menu-item-based-on-current-url) – Turnip 2014-12-05 12:09:04
是......是真的,但只適用於帶有一個標籤的網址(http://www.whatever.com/?tag=汽車)......如果你有多個標籤(http://www.whatever.com/?tag=automotive,big-data),它不起作用 – 2014-12-05 12:14:55
@ LuisP.A。你看到我的代碼了嗎?它適用於你 – clement 2014-12-05 12:21:16