Javascript examples for DOM HTML Element:Audio
The controls property sets or gets whether a audio should display standard audio controls.
Audio controls should include:
Set the controls property with the following Values
Value | Description |
---|---|
true|false | Sets whether a audio should have controls displayed |
A Boolean, returns true if audio controls are displayed, otherwise it returns false
The following code shows how to disable controls for an audio:
<!DOCTYPE html> <html> <body> <audio id="myAudio" controls> <source src="your.ogg" type="audio/ogg"> <source src="your.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>/* w w w. j a va2 s. c om*/ <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myAudio").controls = false; } </script> </body> </html>