I'm trying to build a simple HTML5 music player with JavaScript. I've build a player with this code:
<audio controls="controls">
<source id="song" src="horse.ogg" type="audio/ogg">
</audio>
I've build a couple of <a>
which call function changeSong(n);
function changeSong(n) {
document.getElementById("song").src = "song" + n + ".mp3";
}
and when I click the <a>
's nothing happens to the document, and it won't work..
The <a>
's:
<a href="#1" onclick="changeSong(1)">Play song 1 </a></br>
<a href="#2" onclick="changeSong(2)">Play song 2 </a>
What do to make it work? ////
I tried just running the JavaScript w/o function and it works. but when it's called from the as a function it doesn't...