open tag audio id="song"
source id="file-path" src="media/Kaattumalli.mp3" type="audio/mp3"
audio close tag
I tried many ways to find the solution. But, I failed to take src value into a javascript variable. Anyone Know the trick to solve the problem. Please let me know the trick.
How to take the src file name and store the value in a variable using javascript. Please any help me.
3
Answers
You need to use id of the audio tag to get the element and then you can get attributes from the tag using that element
To retrieve the value of the src attribute from an HTML , tag and store it in a JavaScript variable, than you can use the getAttribute() method.
Here’s an example of how you can achieve this for your case: