如果哈希值(例如)等于#area & id="Hafr",如何将类切换到特定的 html 元素
我需要切换
class="opened"
到这个元素
<div id="hafr"></div>
如果 url 的哈希值 = #area
请在 jsfiddle 中查找我的子菜单! http://jsfiddle.net/samehsubscription/8u5qy/
最佳答案
if (window.location.hash == '#area') $('#hafr').addClass('opened');
谢谢@abhitalks
关于javascript - 根据 URL 的哈希值将类切换到特定元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24265739/