Answer the question
In order to leave comments, you need to log in
How to show hidden block?
What needs to be added in this script so that after pressing the "Show text" button, the text that we have hidden appears again?
<div class="content-area">
<h5 id="text">CONTENT AREA</h5>
<button id="hideBtn">Скрыть текст</button>
</div>
document.getElementById ('hideBtn').onclick = function() {
document.getElementById ('text').hidden = true;
document.getElementById ('hideBtn').innerHTML = "Показать текст";
};
Answer the question
In order to leave comments, you need to log in
<div class="content-area">
<h5 id="text">CONTENT AREA</h5>
<button id="hideBtn">Скрыть текст</button>
</div>
.hide-and-show {
display: none;
}
const btn = document.getElementById('hideBtn');
btn.addEventListener('click', function() {
document.getElementById('text').classList.toggle('hide-and-show');
if (btn.innerHTML === 'Показать текст') {
btn.innerHTML = 'Скрыть текст';
} else {
btn.innerHTML = 'Показать текст';
}
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question