title: Html5 audio successful load check in jquery?
body: <p>I have an audio element, I run it by clicking on the other element, and that element changes style while the sound is playing and back afterwords.</p>
  
  <pre><code>&lt;audio preload="auto" id="axxx"&gt;
    &lt;source type="audio/mpeg" src="sound/xxx.mp3"&gt;&lt;/source&gt;
    &lt;source type="audio/ogg" src="sound/xxx.ogg"&gt;&lt;/source&gt;
    Not supported
  &lt;/audio&gt;
  </code></pre>
  
  <p>But for some elements, I have no audio, so I want to check, if the audio element was successfully loaded.
  I have tried to check the duration, but the condition is always false.</p>
  
  <pre><code>$("#lxxx").click(function () {
      if ($('#axxx').duration &gt; 0) {
          $('#axxx').get(0).play();
          $('#lxxx').css("background-color", "orange");
      }
  });
  $('#axxx').on('ended', function () {
      $('#lxxx').removeAttr('style');
  });
  </code></pre>
  
  <p>What is the way to ensure, if the audio was successfully loaded?</p>