<option selected = “selected”> issues in IE9 [duplicate]

ε祈祈猫儿з 提交于 2020-01-13 20:46:07

问题


I'm having issues with setting a default value in a dropdown menu in IE9. It seems to work on other browsers. All my searches yielded people trying to use JQuery to set that attribute. But I'm not using JQuery at all. Here's a sample:

<select id="selectType" name="selectType">
<option label="1" selected="selected">1</option>
<option label="2">2</option>
<option label="3">3</option>
</select>

I forgot to add that the problem is that it's displaying a blank field as the default instead of "1".


回答1:


That should work just fine, although personally I would take into account that selected is a boolean attribute and therefore its presence is all that is required:

<option label="1" selected>1</option>

That being said, I'm not sure label is a valid attribute there. I'm fairly sure they're inteded for <optgroup> tags. Try removing that attribute.



来源:https://stackoverflow.com/questions/15212174/option-selected-selected-issues-in-ie9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!