button1Toggle()
功能似乎无法运作。按钮中的文字不会改变。无法找到错误。
function button1Toggle() {
if (document.myform.button1.value == "Mute") {
document.myform.button1.value = "Unmute";
} else {
document.myform.button1.value = "Mute";
}
}

<div>Tablet</div><br>
<form name ="myform">
<input type="button" name="button1" id="button1" value="Mute" onclick="button1Toggle()">
</form>
&#13;
答案 0 :(得分:1)
也许你有另一个具有相同ID的按钮?
尝试 -
function button1Toggle(btn) {
if (btn.value == "Mute") {
btn.value = "Unmute";
} else {
btn.value = "Mute";
}
}
<div>Tablet</div><br>
<form name ="myform">
<input type="button" name="button1" id="button1" value="Mute" onclick="button1Toggle(this)">
</form>