jQuery动态添加 主动实现导航效果码
代码想法:
第4:页
5:页
代码想法:
获取链接窗口。位置。路径名;您通过jq打开的页面;
用超文本标记语言给你的li添加一个id。标识的名称与网址链接中的href相同
通过jq包含方法找到对应的li,并为其添加活动类名
然后。不会再有了。
Jq代码:
$(function () { var li=$(')。title _ ul’)。儿童(' Li ');for(var I=0;长度;I){ var URL=window . location . pathname;var url=url.replace('/',' ');if (url.indexOf(li[i])。id)!=-1){ Li[I]. first child . class name=' active ';} else { Li[I]. first child . class name=' ';} }})html代码:
body div class=' title ' ul class=' title _ ul ' Li id=' index ' a href=' index . html ' rel=' external nofollow ' class=' page 1/a/Li Li id=' ZF ' a href=' ZF . html ' rel=' external nofollow ' class=' page 2/a/Li Li id=' GC ' a href=' GC . html ' rel=' external nofollow ' class=' page 3/a/Li Li id=' HC ' a href=' hcf '
以上是对jQuery动态添加思想的详细解释。主动实现边肖介绍的导航效果代码,希望对大家有所帮助。如果你有任何问题,请给我留言,边肖会及时回复你。非常感谢您对我们网站的支持!
版权声明:jQuery动态添加 主动实现导航效果码是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。