Javascript examples for DOM HTML Element:Audio
The muted property sets or gets whether the audio should be sound turned off.
This property reflects the <audio> muted attribute.
Set the muted property with the following Values
Value | Description |
---|---|
true|false | Sets whether the audio output should be muted |
A Boolean, returns true if the audio output is muted, otherwise it returns false
The following code shows how to Turn off sound:
<!DOCTYPE html> <html> <body> <audio id="myAudio" controls muted> <source src="your.ogg" type="audio/ogg"> <source src="your.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio><br> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w ww . j av a 2 s .c om*/ document.getElementById("myAudio").muted = true; } </script> </body> </html>