Start New Discussion Reply to this Discussion HTML5 - Dynamic song change
My code goes something like this:
<div class="pBody">
<audio id="player" name="player" class="player" src="" controls="controls"></audio>
</div>
$(document).ready(function(){
$('.fileTr').click(function() {
var id=this.id;
$('#player').attr("src","../mmc/FileSet/" + id);
var sr = $('#player').attr("src");
alert(sr);
$("#player")[0].play();
});
});
fileTr is a class of table columns each having the file name as its id.
What I am trying to do is, when a person clicks a particular column then the id is passed to the function which sets the 'src' attribute for the audio tag and generates a play event. But its not working!
Thanks!
Related Article: HTML5 CSS Animated Scrolling Menu
is a JavaScript / DHTML / AJAX code snippet by Luckychap that has 4 replies, was last updated 1 year ago and has been tagged with the keywords: animation, css3, html5, javascript, menu.
iammirko
Light Poster
33 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
It seems that line 11 would give error as JQuery id selector returns single element not array.
$("#player").play();
Also check by hard coding the path of audio file in above function(that is without using id)
Luckychap
Posting Pro in Training
445 posts since Aug 2006
Reputation Points: 83
Solved Threads: 61
Skill Endorsements: 0
© 2013 DaniWeb® LLC
Page rendered in 0.0571 seconds
using 2.68MB