title: How to toggle audio play/pause with one button
body: <p>I never really worked with javascript before, but I tried googling for a solution to how to make a play/pause button for audio - and I found what appears to be a good and simple solution on this site:
  <a href="https://stackoverflow.com/questions/27368778/how-to-toggle-audio-play-pause-with-one-button-or-link">How to toggle audio play() pause() with one button or link?</a>
  (PS. I don't have reputation poins enough to comment on Iceman's solution and ask him directly what might be wrong - I would have if I could.)</p>
  
  <p>But, when I paste the code snippets into my document, nothing happens (the resulting text isn't clickable).
  Could some of you take a look and tell me what I'm doing wrong? It's very possible it's something stupid, but I can't see it myself.</p>
  
  <p>Index.html so far:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
   &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"/&gt;
      &lt;title&gt;Ukendt Navn ...&lt;/title&gt;
      &lt;script&gt;
          var myAudio = document.getElementById("myAudio");
          var isPlaying = false;
  
          function togglePlay() {
          if (isPlaying) {
              myAudio.pause()
          } else {
              myAudio.play();
          }
          };
          myAudio.onplaying = function() {
          isPlaying = true;
          };
          myAudio.onpause = function() {
          isPlaying = false;
          };
      &lt;/script&gt;
      &lt;style type="text/css"&gt;
          #content {
              border: 1px solid blue;
              margin: auto;
              max-width: 20vw;
              margin-top: 30vw;
              color: black;
          }
   &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="content"&gt;
          &lt;audio id="myAudio" src="birds.mp3" preload="auto"&gt;&lt;/audio&gt;
          &lt;a onClick="togglePlay()"&gt;Click here to hear.&lt;/a&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My test site: <a href="http://wyrdling.com/other/ukendtnavn/" rel="nofollow noreferrer">http://wyrdling.com/other/ukendtnavn/</a></p>