jquery二级目录选中当前页的css样式
时间:2021-08-06 09:06:38|栏目:jquery|点击: 次
如下所示:
<div class="navlist clear"> <span><a href="/M/Page_32.html" title="内科" >内科</a></span> <span><a href="/M/Page_35.html" title="外科" >外科</a></span> <span><a href="/M/Page_37.html" title="妇产科" >妇产科</a></span> <span><a href="/M/Page_38.html" title="儿科" >儿科</a></span> <span><a href="/M/Page_39.html" title="五官科" >五官科</a></span> <span><a href="/M/Page_40.html" title="中医科" >中医科</a></span> <span><a href="/M/Page_41.html" title="急诊科" >急诊科</a></span> <span><a href="/M/Page_42.html" title="口腔科" >口腔科</a></span> <span><a href="/M/Page_43.html" title="疼痛康复科" >疼痛康复科</a></span> <span><a href="/M/Page_44.html" title="病理科" >病理科</a></span> <span><a href="/M/Page_46.html" title="医技科室" >医技科室</a></span> <script> var url = window.location.href; $(".navlist span a").each(function () { if (url.indexOf($(this).attr("href")) > 0) { $(this).addClass("curent") } }) </script> </div>
js中判断当前页面URL是否包含二级栏目中的url
栏 目:jquery
本文地址:http://www.codeinn.net/misctech/164594.html