<选择的选项=“选择的"> IE9中的问题 [英] <option selected = "selected"> issues in IE9

查看:72
本文介绍了<选择的选项=“选择的"> IE9中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IE9的下拉菜单中设置默认值时遇到问题.它似乎可以在其他浏览器上使用.我所有的搜索都使人们试图使用JQuery设置该属性.但是我根本不使用JQuery.这是一个示例:

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>

我忘了补充一点,问题是它显示的是默认的空白字段,而不是"1".

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

推荐答案

这应该很好,尽管我个人认为selected是布尔属性,因此只需要它的存在:

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>

话虽这么说,但我不确定label是否在其中是有效的属性.我相当确定它们是<optgroup>标签的代表.尝试删除该属性.

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.

这篇关于&lt;选择的选项=“选择的"&gt; IE9中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆