botao salvar localstorage esconder div
by thvinic
HTML
<div id="div" class="cookie-css" style="display: visible">
<p>
lorem lorem lorem
<br>
<a href="https://www.learn-about-cookies.com/" target="blank">Learn more</a>
</p>
<button id="closecookie" onclick="cookies()">Got it</button>
</div>
JavaScript
//get the initial value of cookie banner
let initialValue = localStorage.getItem('cookie-css');
var x = document.getElementById("div");
// if it's not null then the value must have been set earlier
if(initialValue){
x.style.display = initialValue;
}
function cookies() {
if (x.style.display === "visible") {
x.style.display = "none";
}
else {
x.style.display = "none";
}
// set the new display value if it's changed
localStorage.setItem('cookie-css', x.style.display);
console.log(localStorage.setItem)
}