如何使用DOM和vanilla javascript在optgroup中设置选项的值?由于A有多个值,我如何选择20 / A vs 30 / A?与...
document.getElementById('logphase').value = "A";
...将在window.onload
<select id="logphase">
<optgroup label="10">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</optgroup>
<optgroup label="20">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</optgroup>
<optgroup label="30">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</optgroup>
<optgroup label="40">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</optgroup>