获取当前 URL 并与链接的 HREF 进行比较以保持子菜单打开
我有一个简单的菜单,当单击父 LI 时,如果有子 UL 要跟随,该菜单会向下滑动更多 UL...
我试图做到这一点,以便当菜单位于某个目录中时,它将将该菜单扩展为默认而不是关闭。我尝试了一些方法,但就是没能发挥作用。目前,我有一个 IF 语句,将 PATHNAME 与变量进行比较,并只是告诉 ID 保持 UL 打开......这已经是我能得到的最接近的结果。
如果页面 url 与父 UL HREF 相同,关于如何使 UL 保持打开状态,有什么建议吗?
您可以在此处查看代码: http://jsfiddle.net/RvGMQ/
谢谢!
I have a simple menu that slides down more UL when the parent LI is clicked, if there is a child UL to follow...
I am trying to make it so when the menu is in a certain directory it will have that menu expanded by default rather than closed. I have tried a few things, but am just not getting it to work. Currently I have a IF statement comparing the PATHNAME with the Varibles and just telling that ID to keep the UL open... That has been as close as I can get.
Any suggestions on how to make the UL stay open if the page url is the same as the parent UL HREF?
You can see the code here: http://jsfiddle.net/RvGMQ/
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,所以我在这里有事要做。如果您遇到这篇文章,请告诉我是否有更好的方法...
我最终创建了一个名为 MyTitle 的元标记,并为其提供内容来比较 ID,然后根据该元标记显示 UL。
ETC..........
Ok, so I got something to work here. Let me know if there is a better way if you come across this post...
I ended up creating a Meta Tag called MyTitle and gave it content to compare an ID to then display UL based on that Meta Tag.
etc..........