title: Make javascript button to hide or display content toggle
body: <p>I have two buttons and two hidden divs containing different information. I'm trying to work out how to make the content appear when one button is clicked (I've managed to get this working fine) and then if the other button is clicked, the old div hides again and the new one opens.</p>
  
  <p>Essentially:</p>
  
  <p>Click here for content A!    Click here for content B!</p>
  
  <p>When user clicks content A, content A appears. 
  When user clicks content A again, content A disappears.</p>
  
  <p>When user clicks content B, content B appears.</p>
  
  <p>User can also toggle. E.g have content A div open, click content B button and content B is then loaded but content A closes itself.</p>
  
  <p><strong>Here is the JS I'm using:</strong></p>
  
  <pre><code>function ShowDiv() {
  document.getElementById("myDiv").style.display = "";
  }
  
  function ShowDiv2() {
      document.getElementById("myDiv2").style.display = "";
      }
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;input type="button" name="answer" onclick="ShowDiv()" /&gt;
  &lt;input type="button" name="answer2" onclick="ShowDiv2()" /&gt;
  
  &lt;div id="myDiv" style="display: none;"&gt;Hi I'm content a!&lt;/div&gt;
  &lt;div id="myDiv2" style="display: none;"&gt;Hi I'm content B!&lt;/div&gt;
  </code></pre>
  
  <p>At the moment both buttons display content correctly, but when you try to click the other nothing happens.</p>