<div class="tab-pane active" id="mainmenu"> <ul class="nav nav-pills nav-stacked nav-quirk" id="mainul"> <li><a href="{:U('Index/index')}"><i class="fa fa-home"></i> <span>Home</span></a></li> <li><a href="{:U('Mall/index')}"> <i class="fa fa-cube"></i> <span>商场管理</span></a></li> <li><a href="{:U('Mall/seller_list')}"> <i class="fa fa-cube"></i> <span>商户查询</span></a></li> <li><a href="{:U('Mall/info')}"><i class="fa fa-cube"></i> <span>我的信息</span></a></li> <li><a href="{:U('Index/out_login')}"><i class="fa fa-cube"></i> <span>退出系统</span></a></li> </ul> </div> <script> //获取当前地址 var curUrl=document.location.href; var myNav=document.getElementById("mainul").getElementsByTagName("a"); for(var i=0;i<myNav.length;i++) { var links=myNav[i].getAttribute("href"); if(curUrl.indexOf(links)!=-1) { myNav[i].parentNode.className="active"; } } </script>