【发布时间】:2019-08-23 14:07:34
【问题描述】:
声音已静音,因此页面加载时视频会自动播放,我想要一个按钮来禁用所有视频的静音。
我已尝试使用 TagName 和 Class,但无法使其工作。
function toggleMute() {
var video=document.getElementById("dude")
if(video.muted){
video.muted = false;
} else {
video.muted = true;
}
}
<button onclick="toggleMute();">
sound on
</button>
<a href=""><video id="baby" poster="" autoplay muted loop>
<source src="baby.mp4" type="video/mp4"></video></a>
<a href=""><video id="joel" poster="" autoplay loop muted>
<source src="joel.mp4" type="video/mp4"></video></a>
<a href="inside/index.html"> <video id="dude" poster="" autoplay loop muted><source src="dude.mp4" type="video/mp4"></video></a>
我希望所有自动播放的视频都能同时播放声音。
【问题讨论】:
标签: javascript html html5-video autoplay mute