Tho*_*ler 0 html javascript xhtml dom
我有一个启用和禁用选项列表.我知道如何禁用选项元素,但我不知道如何再次启用它.
<select size="1" id="x">
<option value="47" disabled="disabled">Value 47</option>
...
selectElement.options[i].disabled = 'disabled';
// ... how to enable?
Run Code Online (Sandbox Code Playgroud)
它应该使用Plain Javascript而不是JavaScript Framework.(我希望我可以使用Prototype或类似的框架,但我不能介绍其中一个.)
使用setAttribute和removeAttribute:
selectElement.options[i].setAttribute("disabled", "disabled");
selectElement.options[i].removeAttribute("disabled");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1863 次 |
| 最近记录: |