title: More than one modal box on page?
body: <p><strong>Edit</strong></p>
  
  <p>I have updated all the code in this question.</p>
  
  <p><strong>Question</strong></p>
  
  <p>I have been trying to get more than one modal box to work a single page.</p>
  
  <p>I can get one to work but I can't replicate it so that two will open (I want there to be three modal boxes  to in the end?</p>
  
  <p>This is the button that is being called to open the first modal;</p>
  
  <pre><code>    &lt;button id="myHistoryBtn" class="myAboutBtn"&gt;more&lt;/button&gt;
  </code></pre>
  
  <p>This is the second one;</p>
  
  <pre><code>&lt;button id="myAboutBtn" class="myAboutBtn"&gt;more&lt;/button&gt;
  </code></pre>
  
  <p>This is the modal structure that I am using</p>
  
  <pre><code>&lt;div id="myHistoryModal" class="modal"&gt;
  
      &lt;!-- Modal content --&gt;
      &lt;div class="modal-container"&gt;
              &lt;div class="modal-content"&gt;
                  &lt;span class="modalclose"&gt;×&lt;/span&gt;
                  &lt;h1&gt;sstory&lt;/h1&gt;
              &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>This is the second one</p>
  
  <pre><code>&lt;div id="myAboutModal" class="modal2"&gt;
  
            &lt;!-- Modal content --&gt;
          &lt;div class="modal-container"&gt;
                &lt;div class="modal-content"&gt;
                  &lt;span class="Aboutclose" id="close"&gt;×&lt;/span&gt;
                  &lt;h1&gt;AAAAAstory&lt;/h1&gt;
                &lt;/div&gt;
          &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>Then this is the JavaScript that is making everything work.</p>
  
  <pre><code>         // Get the modal
  var modal = document.getElementById('myHistoryModal');
  
  // Get the button that opens the modal
  var btn = document.getElementById("myHistoryBtn");
  
  // Get the &lt;span&gt; element that closes the modal
  var span = document.getElementsByClassName("modalclose")[0];
  
  // When the user clicks the button, open the modal
  btn.onclick = function() {
      modal.style.display = "block";
          main.style.display = "none";
  }
  
  // When the user clicks on &lt;span&gt; (x), close the modal
  span.onclick = function() {
      modal.style.display = "none";
          main.style.display = "flex";
  }
  
  // When the user clicks anywhere outside of the modal, close it
  window.onclick = function(event) {
      if (event.target == modal) {
          modal.style.display = "none";
                  main.style.display = "flex";
      }
  }
  </code></pre>
  
  <p>Here is the JavaScript to get the other modal box to work.</p>
  
  <pre><code>// Get the modal
  var about = document.getElementById('myAboutModal');
  
  // Get the button that opens the modal
  var Abtn = document.getElementById("myAboutBtn");
  
  // Get the &lt;span&gt; element that closes the modal
  var Aspan = document.getElementById("close")[0];
  
  // When the user clicks the button, open the modal
  Abtn.onclick = function(event) {
      about.style.display = "block";
          main.style.display = "none";
  }
  
  // When the user clicks on &lt;span&gt; (x), close the modal
  Aspan.onclick = function() {
      about.style.display = "none";
      main.style.display = "flex";
  }
  
  // When the user clicks anywhere outside of the modal, close it
  window.onclick = function() {
      if (event.target == about) {
          about.style.display = "none";
                  main.style.display = "flex";
      }
  }   
  </code></pre>
  
  <p>I think I am going insane as it all starting to muddle now. Once I try to have more than one modal box it.</p>
  
  <p>I gave it one more go and I sort have got it to work (sort of)</p>
  
  <p>One of the modal box appears when I click the button but won't disappear on close (just stays there)</p>
  
  <p>When I click the other modal box button it hides content but doesn't show the modal box?</p>
  
  <p>Heres a link of what I am working on. I have taken out the code that makes the other modal boxes to work to show you what meant to happen when you click on the more button.</p>
  
  <p><a href="http://www.periodictablesearch.zackreid.com/pages/Carbon.html" rel="nofollow">http://www.periodictablesearch.zackreid.com/pages/Carbon.html</a></p>
  
  <p>This is just confusing me now. I have renamed everything on the second set of JavaScript that makes the second button to work but still nothing.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>So I have now got them to appear and but one is still broken a bit. </p>
  
  <p><a href="http://www.periodictablesearch.zackreid.com/pages/Carbon.html" rel="nofollow">http://www.periodictablesearch.zackreid.com/pages/Carbon.html</a></p>
  
  <p>Then second modal box appears but it won't hide/ close done when using the button our clicking outside the modal box.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I have now gotten the second modal to close when clicking of the window. Just need to make the button work? Is anyone interested? Should I update my code?</p>