Audio muted 属性

定义和用法

muted 属性设置或返回音频输出是否应静音(声音关闭)。

此属性反映 <audio> muted 属性

当设置时,它规定音频输出应该被静音。

实例

例子 1

关闭声音:

document.getElementById("myAudio").muted = true;

亲自试一试

例子 2

查看声音是否关闭:

var x = document.getElementById("myAudio").muted;

亲自试一试

语法

返回 muted 属性:

audioObject.muted

设置 muted 属性:

audioObject.muted = true|false

属性值

描述
true|false

Specifies whether the audio output should be muted.

  • true - indicates that the audio should be turned off
  • false - default. Indicates that the audio should be turned on for the audio

Technical details

Return value: Boolean value, returns true if the audio output is muted, otherwise returns false.
Default value: false

Browser support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support

Related pages

HTML reference manual:HTML <audio> muted attribute