html select - selectedIndex

Original link: http://www.cnblogs.com/HansZimmer/p/10450757.html

<select name="sname">
  <option value="1" selected>Male</option>
  <option value="2">Famale</option>
</select>

I want to select Male:
with document.sname [1] .selected = false; is not possible, selected is read-only.
Should document.sname.selectedIndex = 1; 

Reproduced in: https: //www.cnblogs.com/HansZimmer/p/10450757.html

Guess you like

Origin blog.csdn.net/weixin_30546933/article/details/94794417