0
我正在嘗試構建一個假設讓我的播放器靜音和取消靜音的按鈕。 出於某種原因,我只能靜音,但不能取消靜音播放器。 相同的功能適用於播放/暫停按鈕... 任何人有任何iade?如何靜音和取消靜音播放器按鈕?
<html>
<head></head>
<body>
<input type='button' onclick="muteUnMute()" value='Mute' class="btn_random" id="muteunmute"/>
<audio controls="controls" preload autoplay="autoplay" id="audio1" volume="1.0"></audio>
<script type="text/javascript">
function muteUnMute() {
var muteSound = document.getElementById("audio1");
x = new Boolean(muteSound.muted=false);
if (x) {
document.getElementById('audio1').muted = true;
document.getElementById("muteunmute").value="Un-Mute";
} else {
document.getElementById('audio1').volume="1.0";
document.getElementById("muteunmute").value="Mute";
}
}
</script>
</body>
謝謝!
我想你的意思是'X =新的布爾(muteSound.muted ==假);',或者更好的,'X! muteSound.muted;' – 2014-10-08 20:11:54
使用'x =!muteSound.muted;'如Paul Roub所說的 – sircapsalot 2014-10-08 20:13:11