Answer the question
In order to leave comments, you need to log in
How to hide a div block permanently?
Hey! I have a simple authorization form (Password, Name) when all fields are filled in, and when I click on the buttons, the div block is hidden.
So, but when the page is updated, it is shown again, how can I hide it forever after the first authorization?
Answer the question
In order to leave comments, you need to log in
<div id="hide_forever">
Div, который прячется навсегда
</div>
<button id="button1">Скрыть DIV</button>
<script>
const div = document.getElementById('hide_forever');
const button = document.getElementById('button1');
const status = localStorage.getItem('div_hidden');
if (status) {
div.style.display = 'none';
}
button.addEventListener('click', () => {
localStorage.setItem('div_hidden', '1');
div.style.display = 'none';
});
</script>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question