您好我有一个select元素,我正在尝试为该select元素设置一个默认选项。但是我的代码在IE中不起作用。有没有办法解决这个问题?
if(objOption.value == selectedoption)
{ alert(objOption.value);
objOption.defaultSelected = true;
}
我可以检索该选项及其值,但无法设置defaultSelected值。
答案 0 :(得分:4)
正如documentation中所述,仅当您点击defaultSelected
时才会使用<input type="reset" />
属性。
要立即选择<option>
,您还应将selected
属性设置为true
。