Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h3>A demonstration of how to access a SOURCE element</h3> <audio controls> <source id="mySource" src="horse.mp3" type="audio/mpeg"> <source src="horse.ogg" type="audio/ogg"> Your browser does not support the audio element. </audio> <p>Click the button to get the URL of the media file.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("mySource").src; document.getElementById("demo").innerHTML = x; } </script> </body> </html>