The controls property sets or gets if a <audio> should show standard audio controls.
This property mirrors the <audio> controls
attribute.
When present, the audio controls will be displayed.
Possible value:
Value | Meaning |
---|---|
true | controls are displayed |
false | Default. controls are NOT displayed |
Find out if the audio controls are displayed:
var x = document.getElementById("myAudio").controls;
Click the button to find out if the audio controls are displayed.
<!DOCTYPE html> <html> <body> <audio id="myAudio" controls> <source src="sound.ogg" type="audio/ogg"> <source src="sound.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>//from w ww . ja v a 2 s. c om <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myAudio").controls; document.getElementById("demo").innerHTML = x; } </script> </body> </html>