title: How do I make this use the same button for open and close
body: <p>So I'm using the following script; which opens and closes a side bar.</p>
  
  <pre><code>function openNav() {
      document.getElementById("mySidenav").style.width = "250px";
  }
  
  function closeNav() {
      document.getElementById("mySidenav").style.width = "0";
  }
  </code></pre>
  
  <p>What I'm trying to achieve is instead of having two buttons like;</p>
  
  <pre><code>&lt;a href="#" onclick="openNav()"&gt;Open&lt;/a&gt;
  
  &lt;a href="#" onclick="closeNav()"&gt;Close&lt;/a&gt;
  </code></pre>
  
  <p>Is to have one button that performs both actions like the first time its clicked opens the side bar and the second time it gets clicked the side bar closes.</p>