Posts

Showing posts with the label html5-audio

Issues with multiple audio files in HTML onclick

Issues with multiple audio files in HTML onclick I am creating an online instrument that has 10 keys, each with a recorded sound to play on click. At the moment it is only playing the first sound and I can't work out what I need to do in my code to get the other audio files to play. I have looked at multiple links to try and solve this but nothing has worked! <h1> Click to Play <script> function play(){ var audio = document.getElementById("audio"); audio.play(); } </script> <img src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/2124473 /Low_2.jpeg' value="PLAY" onclick="play()"><audio id="audio" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/2124473/low%202.mp3" ></audio> <img src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/2124473/Low_3.jpeg' value="PLAY" onclick="play()"><audio id="audio" src="https://s3-us-...