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

 

 

转载于:https://www.cnblogs.com/qigege/p/5363581.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值