选择样式添加
menuToggle: function() { var menus = $('.nav-primary').children('li'); var tog = menus.has('.nav-secondary').children('a'); tog.on('click', function(event) { event.preventDefault(); var $this = $(this); menus.not($this.parent('li')).removeClass('active').children('.nav-secondary').slideUp(200); $this.parent('li').toggleClass('active').children('.nav-secondary').slideToggle(200); }); } <div class="aside"> <ul class="nav-primary"> <li> <a href="/index.php/dashboard"><i class="icon-dashboard"></i>控制板</a> </li> <li> <a href="/index.php/ticket/ticket_list"><i class="icon-file"></i>工单</a> <span class="caret"></span> <ul class="nav-secondary"> <li><a href="/index.php/ticket/ticket_list"><i class=""></i>我的工单</a></li> </ul> </li> <li class="current active"> <a href="/index.php/om"><i class="icon-sitemap"></i>运维</a> <span class="caret"></span> <ul class="nav-secondary"> <li class="active"><a href="/index.php/om"><i class=""></i>主机</a></li> <li><a href="/index.php/report/omreport/overview"><i class=""></i>报表</a></li> <li><a href="/index.php/omrequest/request"><i class=""></i>审批</a></li> </ul> </li> </ul> </div>