<!DOCTYPE html>
<html>
<body>
<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 return the value of the type attribute of the media resource.</p>
<p id="demo"></p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
var x = document.getElementById("mySource").type;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>