title: HTML - How to play and pause audio when clicking an image?
body: <p>I've tried a code that I found here on this website, but for some reason it won't work. Hope someone here could help. It plays the song when I click the gif, but when I click the gif again, it just replays it. <br>
  Here's the code I used:</p>
  
  <pre><code>&lt;img src="lilgif.gif" alt="Play Button" onclick="StartOrStop('boss.mp3')"&gt;
  
  &lt;audio id="myAudio"&gt;&lt;/audio&gt;
  </code></pre>
  
  <p>Script:</p>
  
  <pre><code>function StartOrStop(audioFile) {
  var audio = document.getElementById("myAudio");
  if (!audio.src || audio.src !== audioFile) audio.src = audioFile;
  if (audio.paused == false)
      audio.pause();
  else
      audio.play();
  }
  </code></pre>