What I want to achieve is a folding menu, but the slidetoggle can only be collapsed by clicking on it. What I want is to click on other options and the expanded menu will automatically collapse. How can I modify it?
The code is as follows:
$("> li", this).each(function () {
$(this).bind("click", function () {
if($(this).hasClass('active')){
//$(".inner ol").hide();
//$(this).siblings("ol").slideToggle(settings.speed);
$(this).next("ol").slideToggle(settings.speed);
$(this).removeClass('active');
}else{
$(this).siblings('li').removeClass('active');
//$(".inner ol").hide();
$(this).addClass('active')
$(this).next("ol").slideToggle(settings.speed);
}
});
});
//默认折叠
$("> ol", this).hide();
The idea is as follows:
1. When you click on the current menu, record it, first close all open menus, and finally open yourself
The above code is just a demonstration example, give me a rough idea and see if it works
I checked the information online and found that there is a slideup() function. Just use it to replace hide(). Thank you!
$("> li", this).each(function () {