如下所示:
<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樣式就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持。