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!

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.