我真的很想知道为什么在下面的代码function(next)中使用它很重要。next()如果没有next(),您只能.open-sidebar在添加该类后通过单击 删除一次.header__menu__button--profile。
我以为next()是用来选择元素的以下同级的!
为什么.open-sidebar每次单击时都需要它来删除类.sidebar__top__button--close?
$('.header').on('click','.header__menu__button--profile',function(){
$('.sidebar').addClass('open-sidebar');
});
$('.sidebar').on('click','.sidebar__top__button--close',function() {
if($('.sidebar').hasClass('open-sidebar'))
{
$('.sidebar').delay(300).queue(function(next){
$('.sidebar').removeClass('open-sidebar');
next();
});
}
});