标签:func 导航 ack ati query win 导航栏 each nbsp
html:
<div class="nav">
<ul>
<li class="active"><a href="a.html">aaa</a></li>
<li><a href="b.html">bbb</a></li>
<li><a href="c.html">ccc</a></li>
</ul>
</div>
jquery:
$(".nav li a").each(function (i) {
var $me = $(this);
var lochref = $.trim(window.location.href);
var mehref = $.trim($me.get(0).href);
if (lochref.indexOf(mehref) != -1) {
$me.parent().addClass("active");
} else {
$me.parent().removeClass("active");
}
});
css:
.active{background-color:#ed0505;}
标签:func 导航 ack ati query win 导航栏 each nbsp
原文地址:http://www.cnblogs.com/flfirst/p/7687383.html