Jquery 打开其他按钮时如何从按钮中删除活动
代码: 在单击其他子菜单列表的按钮时,管理删除/添加选定项。但当单击下一个子菜单列表的下一步按钮时,按钮仍处于活动状态。单击“下一步”按钮时,无法删除或添加活动的 不确定它为什么不起作用请参见注释行Jquery 打开其他按钮时如何从按钮中删除活动,jquery,Jquery,代码: 在单击其他子菜单列表的按钮时,管理删除/添加选定项。但当单击下一个子菜单列表的下一步按钮时,按钮仍处于活动状态。单击“下一步”按钮时,无法删除或添加活动的 不确定它为什么不起作用请参见注释行 $('.touch-button').on('click', function(e) { var $touchButton; $touchButton = $(this).parent('.item-with-ul').find('>span.touch-button
$('.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');
});
简单地说
$('.touch-button').on('click', function(e) {
$(this).removeClass('active');
});
我想你需要的是
$('.touch-button').on('click', function(e) {
$('.touch-button').removeClass('active');// remove active from all touch-button
$(this).addClass('active'); // current touch button is active only now
)};
使用e.stop即时复制
你们能贴一把小提琴吗?几乎并没有,因为当点击同一个按钮两次时,它不会显示所选的类。同时,当点击下一步按钮时,它也不会显示子菜单
$('.touch-button').on('click', function(e) {
$('.touch-button').removeClass('active');// remove active from all touch-button
$(this).addClass('active'); // current touch button is active only now
)};
$('.touch-button').on('click', function(e) {
$('.touch-button').removeClass('active');
$('.item-with-ul').removeClass('selected');
$('.flexnav-show').hide();
$(this).addClass('active') // make current touch button active
.closest('.flexnav-show').show() // show the closest ul
.closest('.item-with-ul').addClass('selected'); //add the selected class to list item
});
$(document).ready(function(e){
e.stopImmediatePropagation();
$('.touch-button').removeClass('active');// remove active from all touch-button
$(this).addClass('active'); // current touch button is active only now
});