+ 2

Change of source file through js

does anyone know how to change the attribute value of src in audio tag through js

11th Sep 2017, 12:31 PM
Vijeth Belle
Vijeth Belle - avatar
3 Respuestas
+ 1
const audioEl = document.getElementById('my-audio'); audioEl.setAttribute('src', 'my-track.mp3');
12th Sep 2017, 3:53 AM
Alex N
Alex N - avatar
+ 1
I tried that but it didn't work
13th Sep 2017, 2:22 AM
Vijeth Belle
Vijeth Belle - avatar
+ 1
You have to call audioEl.load(); after that, I suppose.
13th Sep 2017, 4:28 AM
Alex N
Alex N - avatar