在IE中使用javascript选择html的默认选定选项

在IE中使用javascript选择html的默认选定选项,javascript,internet-explorer,default,Javascript,Internet Explorer,Default,您好,我有一个select元素,我正在尝试为该select元素设置一个默认选项。但我的代码在IE中不起作用。有没有办法解决这个问题 if(objOption.value == selectedoption) { alert(objOption.value); objOption.defaultSelected = true; } 我可以检索该选项及其值,但无法设置defaultSelected值。如中所述,defaultSelected属性仅在单击某个时使用 要立即选择,还应将选定的属性设置为

您好,我有一个select元素,我正在尝试为该select元素设置一个默认选项。但我的代码在IE中不起作用。有没有办法解决这个问题

if(objOption.value == selectedoption)
{ alert(objOption.value);
objOption.defaultSelected = true;
}
我可以检索该选项及其值,但无法设置defaultSelected值。

如中所述,
defaultSelected
属性仅在单击某个
时使用

要立即选择
,还应将
选定的
属性设置为

,如中所述,只有在单击
时才使用
默认选定的
属性

要立即选择
,还应将
选定的
属性设置为

得到答案
objOption.selected=true
适用于IE:DGot答案
objOption.selected=true
在IE中工作:D