0

I wanted a nice and simple way to play a sound once, right when the document is ready.

As I searched for clues online I found a lot, but none were that explanatory, so what I am asking is for some help on how to build this on the most browser compatible and light way.

Thanks ;)

gespinha
  • 7,968
  • 16
  • 57
  • 91
  • possible duplicate of [Playing audio with Javascript?](http://stackoverflow.com/questions/9419263/playing-audio-with-javascript) – DGS Sep 05 '13 at 00:33

1 Answers1

3

Use this Markup

<audio id="sound_tag" src="your_audio_file.wav" preload="auto"></audio>
<script type="text/javascript">
    $(document).ready(function(){
        $('#sound_tag')[0].play();
    });
</script>
DGS
  • 6,015
  • 1
  • 21
  • 37