menu open onload problem code example
Example 1: menu open onload problem
(function() {
if(window.localStorage.getItem('nav') === null){
window.localStorage.setItem('nav', 'none');
}
var x = document.getElementById("nav");
x.style.display = window.localStorage.getItem('nav');
})();
function myFunction() {
var x = document.getElementById("nav");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
window.localStorage.setItem('nav', x.style.display);
}
Example 2: menu open onload problem
#nav{
display:none;
}
Example 3: menu open onload problem
(function() {
var x = document.getElementById("nav");
x.style.display = "none";
})();