次のコードでfunction(next)
andを使用することが重要な理由を本当に知りたいです。next()
なしでは、クラスを追加した後、 をクリックして 1 回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();
});
}
});