<li class="submenuList item-with-ul selected">
<a href="#">Blalab</a>
<ul class="sub-nav flexnav-show" style="display: block;">
<li><a href="#">Highlights</a></li>
<li><a href="#">Invited</a></li>
<li><a href="#">Talks</a></li>
</ul>
<span class="touch-button active"><i class="fa fa-chevron-down navicon"></i></span>
</li>
脚本:
$('.touch-button').on('click', function(e) {
var $touchButton;
$touchButton = $(this).parent('.item-with-ul').find('>span.touch-button');
$parent = $(this).parent('.item-with-ul');
$(".flexnav ul").removeClass('flexnav-show').hide();
$(this).parent().not('.selected').addClass('selected');
$('.selected').removeClass('selected');
//couldn't figure how to remove active from touch-button and add active as so to close and open the submenu
//$(this).removeClass('active');
// $touchButton.removeClass('active');
});
托管删除/添加时,选择点击按钮,其他子菜单列表。但是当点击下一个子菜单列表中的下一个按钮时,按钮仍处于活动状态。单击下一个按钮时,无法获取要删除或添加的活动。
不知道为什么它不工作(见注释行)
你可以发布小提琴吗? – 2015-03-25 06:39:00