Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Slava Kulpichev already answered, but for the future - any mikruha whose name starts with 25qXXX
You can remove all possible classes :
const classes = $buttons.get().map(n => n.dataset.set);
$buttons.click(function() {
$('.current').removeClass('current');
$(this).addClass('current');
$blocks.removeClass(classes.join(' ')).addClass(this.dataset.set);
});
let currentClass = null;
$buttons.click(function() {
$('.current').removeClass('current');
$(this).addClass('current');
const newClass = this.dataset.set;
$blocks.removeClass(currentClass).addClass(newClass);
currentClass = newClass;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question