长时间听众,第一次来电...我有一个音乐测试,要求用户识别音高,在正确答案后,我需要选择选项的值重置为“禁用”选择&#39。尝试过多次但没有运气。任何帮助将不胜感激!
$("#pitchBtn").click(function() {
if (gameFinished) {
// Clear the value of the option in the select element here
}
}

<select id="selectText">
<option value="" disabled selected>Enter your guess</option>
<option value="C"></option>
<option value="D">D</option>
<option value="E">E</option>
</select>
&#13;
答案 0 :(得分:0)
尝试
{{1}}
答案 1 :(得分:0)
我建议:
// cache the relevant <option> element,
// retrieve that element using
// document.querySelectorAll() to select
// the first, if any, element matching the
// supplied CSS selector:
let defaultOption = document.querySelectorAll('option[value=""]');
// set the 'selected' property to true:
defaultOption.selected = true;
// set the 'disabled' property to true:
defaultOption.disabled = true;