Javascript examples for DOM HTML Element:Source
The type property sets or gets the value of the type attribute in a <source> element, which sets the MIME type of the media resource.
Set the type property with the following Values
Value | Description |
---|---|
MIME_type | Sets the MIME type of the media resource. |
Common MIME types:
A String, representing the MIME type of the media resource
The following code shows how to return the MIME type of a media resource:
<!DOCTYPE html> <html> <body> <audio controls> <source id="mySource" src="your.mp3" type="audio/mpeg"> <source src="your.ogg" type="audio/ogg"> Your browser does not support the audio element. </audio>/* ww w .j a va 2s. com*/ <p id="demo"></p> <button onclick="myFunction()">Test</button> <script> function myFunction() { var x = document.getElementById("mySource").type; document.getElementById("demo").innerHTML = x; } </script> </body> </html>