![]() Now we are going to create two buttons to change the music of our HTML5 player. So actually we just have to change the src file of our HTML5 audio player and it changes the audio. In our code we take the advantage of the setAttribute() method to change the audio file of our HTML5 audio player. In the above snippet, we have used the JavaScript setAttribute() that used to change the attribute of any HTML element. You can change the audio file of the HTML5 player with just one line of JavaScript code that you can see below: document.getElementById("my-audio").setAttribute('src', 'AUDIO_SRC_FILE') ![]() It is quite easy to change the music file of an HTML5 audio player with JavaScript. ![]() In this post, I am going to show you how can you change HTML5 audio player src file in Javascript.
0 Comments
Leave a Reply. |