用js实现超链接导航菜单点击切换选中时的状态
<div class="row border-bottom">
<div class="col-lg-12">
<div class="tab_title">
<ul class="nav nav-pills">
<li class="current">
<a href="/my">我的主页</a>
</li>
<li>
<a href="/setting">设置</a>
</li>
</ul>
</div>
</div>
</div>
tabTitle: function () {
var urlstr = location.href;
var urlstatus = false;
$(".tab_title ul li a").each(function () {
if ((urlstr + '/').indexOf($(this).attr('href')) > -1 && $(this).attr('href') != '') {
$(this).parent("li").addClass('current');
urlstatus = true;
} else {
$(this).parent("li").removeClass('current');
}
});
}