title: JS - Opening Sub Nav while Closing previously opened Sub-Nav
body: <p>I'm just starting Javascript and I'm trying to get a sub-menu of a side Nav to preform two functions (open desired sub-menu while closing any currently open sub-menu)</p>
  
  <p>This is the current state of things:</p>
  
  <p><a href="https://jsfiddle.net/dangeruss/r67Lzpnh/5/" rel="nofollow noreferrer">https://jsfiddle.net/dangeruss/r67Lzpnh/5/</a></p>
  
  <p>I was thinking about:</p>
  
  <pre><code>function toggleNav() {
  var element = document.getElementById("mySidenav2");
  if (element.style.width == "250px") {
      element.style.width = "0px";
  } else {
      element.style.width = "250px";
  }
  </code></pre>
  
  <p>But i'm un-sure how to close any sidenave open (mySidenavX) and open mySidenav3 etc.</p>