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

人只需不取得标的目标,就不会取得自己。有没有人爱,我们也要努力做一个可爱的人。不埋怨谁,不嘲笑谁,也不羡慕谁,阳光下灿烂,风雨中奔跑,做自己的梦,走自己的路。

如下所示:

<div class="navlist clear">

 
<span><a  rel="nofollow noopener noreferrer" href="/M/Page_32.html"  title="内科" >内科</a></span>

<span><a  rel="nofollow noopener noreferrer" href="/M/Page_35.html"  title="外科" >外科</a></span>

<span><a  rel="nofollow noopener noreferrer" href="/M/Page_37.html"  title="妇产科" >妇产科</a></span>

<span><a  rel="nofollow noopener noreferrer" href="/M/Page_38.html"  title="儿科" >儿科</a></span>

<span><a  rel="nofollow noopener noreferrer" href="/M/Page_39.html"  title="五官科" >五官科</a></span>

<span><a  rel="nofollow noopener noreferrer" href="/M/Page_40.html"  title="中医科" >中医科</a></span>

<span><a  rel="nofollow noopener noreferrer" href="/M/Page_41.html"  title="急诊科" >急诊科</a></span>

<span><a  rel="nofollow noopener noreferrer" href="/M/Page_42.html"  title="口腔科" >口腔科</a></span>

<span><a  rel="nofollow noopener noreferrer" href="/M/Page_43.html"  title="疼痛康复科" >疼痛康复科</a></span>

<span><a  rel="nofollow noopener noreferrer" href="/M/Page_44.html"  title="病理科" >病理科</a></span>

<span><a  rel="nofollow noopener noreferrer" 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