title: Javascript play multiple audio in loop
body: <p>I create html and javascript for play sound number :</p>
  
  <pre><code>&lt;audio id="audio_0" src="0.wav" &gt;&lt;/audio&gt;
  &lt;audio id="audio_1" src="1.wav" &gt;&lt;/audio&gt;
  &lt;audio id="audio_2" src="2.wav" &gt;&lt;/audio&gt;
  &lt;audio id="audio_3" src="3.wav" &gt;&lt;/audio&gt;
  &lt;audio id="audio_4" src="4.wav" &gt;&lt;/audio&gt;
  &lt;audio id="audio_5" src="5.wav" &gt;&lt;/audio&gt;
  &lt;audio id="audio_6" src="6.wav" &gt;&lt;/audio&gt;
  &lt;audio id="audio_7" src="7.wav" &gt;&lt;/audio&gt;
  &lt;audio id="audio_8" src="8.wav" &gt;&lt;/audio&gt;
  &lt;audio id="audio_9" src="9.wav" &gt;&lt;/audio&gt;
  Number:
  &lt;input type="text" name="number" id="number" size="40"&gt;
  &lt;button onclick="playSound()"&gt;Sent&lt;/button&gt;
  
   &lt;script type="text/javascript"&gt;
    function playSound() {
      var number = document.getElementById('number').value;
      var sound;
      var i = 0;
      if (number &lt;= 999) {
        while(i &lt; number.length) {
          sound = document.getElementById("audio_"+number.substring(i, i+1));           
          setTimeout(function() {
            sound.play();
          } ,1000);
          i++;
        }
      }
    }
  &lt;/script&gt;
  </code></pre>
  
  <p>But when input number (such as 123) it play 3.wav or if not setTimeout it play <code>1.wav</code> - <code>2.wav</code> - <code>3.wav</code> in the same time.</p>
  
  <p>I want it play <code>1.wav</code> - <code>delay</code> - <code>2.wav</code> - <code>delay</code> - <code>3.wav</code> </p>