Answer the question
In order to leave comments, you need to log in
How to hide one class and show another on button click?
There is a button
How to make it so that when you click on it, one class is immediately hidden, and another class is shown, with remembering cookies? And the next time you clicked, the first class was shown again, and the second one also disappeared with remembering the cookie. There is a solution here , but there seems to be without remembering cookies <button id="pinyin-btn"> Сменить плеер</button>
Answer the question
In order to leave comments, you need to log in
Option with adding / removing a class on a button click:
document.getElementById('pinyin-btn').onclick= function(e) {
// По клику будет появляться / исчезать класс className
this.classList.toggle('className');
if(this.classList.contains('className')) {
// Ставим кукис
} else {
// Удаляем кукис
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question