Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

menu open onload problem

// self executing function
(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);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #menu #open #onload #problem
ADD COMMENT
Topic
Name
9+7 =