title: How do I get Html5 audio to play sound on click? (ogg for browsers like Firefox and mp3 for browsers like chrome)
body: <p>How do I get Html5 audio to play sound on click? (ogg for browsers like Firefox and mp3 for browsers like chrome)</p>
  
  <p>So far onclick I can change to a single filetype but I can't get it to have a backup option like you do on a normal html5 audio declaration i.e.</p>
  
  <pre><code>&lt;audio controls&gt;
    &lt;source src="horse.ogg" type="audio/ogg"&gt;
    &lt;source src="horse.mp3" type="audio/mpeg"&gt;
  Your browser does not support the audio element.
  &lt;/audio&gt; 
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  
  &lt;head&gt;
  &lt;meta content="text/html; charset=utf-8" http-equiv="Content-Type" /&gt;
  &lt;title&gt;How do i call the javascript function and get it to play .ogg if can't play .mp3?&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;audio id="Mp3Me" autoplay autobuffer controls&gt;
    &lt;source src="Piano.mp3"&gt;
  &lt;/audio&gt;
  
  &lt;a href="javascript:GuitarTrack()"&gt;Guitar&lt;/a&gt;
  
  &lt;script type="text/javascript"&gt;
  function GuitarTrack(){
  var Mp3Me= document.getElementById('Mp3Me');
  Mp3Me.src = "Guitar.mp3";
  Mp3Me.src = "Guitar.ogg";
  }
  &lt;/script&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>