0

HTML

<audio controls id="controls">
    <source src="Song.mp3" type="audio/mpeg">
</audio>

JavaScript

var FileName = document.getElementById("controls").src

alert(FileName) I am trying to make the alertbox say the source name (Song.mp3) not sure how to do this help!

  • Have you seen this http://stackoverflow.com/a/3732711/2853600 ? You can use document.querySelector("#controls > source").src – Alex Oct 08 '13 at 10:41

2 Answers2

0
var FileName = $("source").attr('src');
Joke_Sense10
  • 5,341
  • 2
  • 18
  • 22
0

do:

var FileName = document.getElementById("controls").getElementsByTagName("source")[0].src;
Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162