I really want to know why it's important to use function(next)
and next()
in the following code. Without next()
you can only remove the class .open-sidebar
one time after you added it by clicking the .header__menu__button--profile
.
I thought next()
is used to select the following sibling of an element!
Why do I need it to remove the class .open-sidebar
every time I click on .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();
});
}
});