简体   繁体   中英

default selected option for html select using javascript in IE

Hello I have a select element and I am trying to set a default option for that select element. But my code isn't working in IE. Is there any way around for this??

if(objOption.value == selectedoption)
{ alert(objOption.value);
objOption.defaultSelected = true;
}

I am able to retreive the option, and its value, but am unable to set the defaultSelected value.

As stated in the documentation , the defaultSelected property is only used if you click an <input type="reset" /> .

To immediately select the <option> , you should also set the selected property to true .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM