Reputation: 2143
I read the HTML5 Audio reference on W3Schools and tried to figure out how to change songs. Their example shows changing a video. I want to do this using jquery when I click on a particular song.
The song I click on has the id #song-two
$("#song-two").click(function() {
$("#mp3_src").src("songs/songtwo.mp3");
});
but the song does not get loaded. Any ideas?
Upvotes: 0
Views: 303
Reputation: 98901
Have you tried?
$("#audiochange").attr("src","songs/songtwo.mp3");
You can also try to provide the full url, i.e.:
$("#audiochange").attr("src","http://yoursite.com/songs/songtwo.mp3");
References:
Upvotes: 1
Reputation: 25352
Try this
$("#song-two").click(function() {
$("#mp3_src").attr("src", "http://example.com/new_url.mp4")
});
instead of
$("#song-two").click(function() {
$("#mp3_src").src("songs/songtwo.mp3);
});
Upvotes: 2