网络学院 w3pop社区 网络资源 IT新闻

w3pop.com :: 网络学院 :: HTML :: HTML <option>标签

会员登陆

帐号

密码

回答

记住密码

忘记密码? 注册

HTML <option>标签


作者:w3pop.com 翻译/整理:w3pop.com 发布:2007-04-28 浏览:2814 :: ::

定义与用法

The option element defines an option in the drop-down list.
option元素定义了下拉列表的可选项目


在HTML和XHTML中的区别

In HTML the <option> tag has no end tag.
HTML中<option>标签不需要关闭

In XHTML the <option> tag must be properly closed.
在XHTML中<option>标签必须合理关闭


提示与注意点

Note: The <option> tag can be used without any attributes, but you usually need the value attribute, which indicates what is sent to the server.
注意:<option>标签不需要任何属性,但一般情况下应该需要value属性,这可以表明发送给服务器的是什么值

Note: Use this tag in conjunction with the select element, elsewhere it is meaningless.
注意:这个标签应该和select元素一起使用,不然它一点意义也没有


实例

代码 输出
<select>
<option value ="volvo">Volvo</option>
<option value ="saab">Saab</option>
<option value ="opel" selected="selected">Opel</option>
<option value ="audi">Audi</option>
</select>


可选属性

DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.
下表中的DTD列指明了被支持的DTD属性。S=Strict(精确的),T=Transitional(传统的),F=Frameset(框架)

属性 描述 DTD
disabled disabled Specifies that the option should be disabled when it first loads
当它第一次被加载的时候可选项不可用
STF
label text Defines a label to use when using <optgroup>
当使用<optgroup>时定义一块标签
STF
selected selected Specifies that the option should appear selected (will be displayed first in the list)
指定为默认选中的项目
STF
value text Defines the value of the option to be sent to the server
定义可选项发送到服务器上的值
STF

标准属性

id, class, title, style, dir, lang, xml:lang, tabindex

For a full description, go to Standard Attributes.
查看完整的属性

事件属性

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

For a full description, go to Event Attributes.
查看完整的属性


尝试与演示

Simple drop down box
How to create a simple drop-down box on an HTML page. A drop-down box is a selectable list.
如何在HTML中建立简单的下拉框。

Another drop down box
How to create a simple drop-down box with a pre-selected value.
如何建立带有预选值的下拉框

评论 (0) All