I want to check if the state of show to change the innerText of the button according to it but when I run it the else statment doesnt work
let showBtn = document.querySelector('.show-more');
showBtn.onclick = function () {
let show = false;
if (show === false) {
showBtn.innerText = 'Show Less';
show = true;
} else {
showBtn.innerText = 'Show more';
}
}
Aucun commentaire:
Enregistrer un commentaire