Issue with fly out menu using javascript

I have a menu that flies out, however it will not return to its original state.

let toggleNavStatus = function () {
  let toggleNavStatus = true;
  let getsidebar = document.querySelector(".sidebar");
  if (toggleNavStatus === true) {
    getsidebar.style.left = "0px";
  } else if (toggleNavStatus === false) {
    getsidebar.style.left = "-250px";
  }
}

5 thoughts on “Issue with fly out menu using javascript”

  1. This should work:

    let toggleNavStatus = false;
    let toggleNavStatus = function () {
    let getsidebar = document.querySelector(".sidebar");
    if (toggleNavStatus === true) {
      getsidebar.style.left = "0px";
    } else {
      getsidebar.style.left = "-250px";
    }
    toggleNavStatus = !toggleNavStatus;
    }
    
    Reply

Leave a Comment