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
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17