我有一个下拉框,我想根据值选择选项。不知何故,我开始处理值(value)说 3
。现在我想手动选择值为 3
的选项。
我试过这样的
selectBoxElement.options[selectedValues].selected = true;
其中 selectedValue = 3
,但它不起作用。
最佳答案
如果使用 jquery(根据您的标签),您可以:
$(document).ready(function() { $("#yourSelectId option[value='3']").attr("selected", "selected"); });
关于javascript - 使用值选择选择框的选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8818074/