问题
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