jquery二级目录选中当前页的css样式

如下所示:

<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二级目录选中当前页的css样式

jquery二级目录选中当前页的css样式

相关推荐