定义
表示 SELECT 元素中的一个选项。
Denotes one choice in a SELECT element.
注释
在 Internet Explorer 5 及以后版本中,OPTION 元素是 all 集合的一部分。而在较早版本中,你只能通过 SELECT 元素的 options 集合获得对这些元素的访问。
你只能在与 OPTION 位于同一窗口的 SELECT 元素里添加 OPTION 元素。
除了 background-color 和 color,通过 style 为 option 元素指定的样式设置都将被忽略。此外,直接应用到单个 options 的样式将覆盖应用到 SELECT 元素容器的样式。
此元素在 Internet Explorer 3.0 及以上版本的 HTML 和脚本中可用。
此元素是一个块元素。
此元素不需要关闭标签。
As of Internet Explorer 5 and later, the OPTION elements are part of the all collection. For earlier versions, you can gain access to these elements by applying the options collection to the SELECT element.
You can add OPTION elements only to a SELECT element that is located in the same window where the OPTION elements are created.
Except for background-color and color, style settings applied through the style object for the option element are ignored. In addition, style settings applied directly to individual options override those applied to the containing SELECT element as a whole.
This element is available in HTML and script as of Internet Explorer 3.0.
This element is a block element.
This element does not require a closing tag.
示例代码
下面的例子使用 OPTION 元素创建了下拉列表框中的单个项目。
<SELECT ID="oCars" SIZE="1" onchange="fnChange()">
<OPTION VALUE="1">宝马
<OPTION VALUE="2">保时捷
<OPTION VALUE="3" SELECTED>大奔
</SELECT>
<TEXTAREA ID="oData"></TEXTAREA>
下面的例子使用 options 集合将列表框中选中的项目追加到文本区域中。
<SCRIPT LANGUAGE="JScript">
function fnChange(){
oData.value+=oCars.options[oCars.selectedIndex].text + "\n";
}
</SCRIPT>
HTML元素 - option
原创文章如转载,请注明:转载自悠悠博客 [ http://www.ajaxstu.com/ ]
相关文章:
- onsubmit="return false;"(2007-10-25 4:0:0)
- 限制TextArea区的文字输入数量(2007-9-26 6:30:36)
- 判断checkbox是否至少有选择一项(2007-9-12 8:42:1)
- ASP表单与用户输入区域(2007-8-7 1:27:35)
- 可编辑的SELECT(2007-7-5 9:14:19)
- 简单的表单验证(后台验证)(2007-7-3 4:27:19)
- ASP连动下拉列表从数据库读取(2007-6-20 1:45:55)
- HTML元素 - input type=hidden(2007-6-15 1:57:14)
- 使用ASP与JAVASCRIPT配合实现多个复选框数据关联显示(2007-5-12 10:14:57)
- 表单:按钮(2007-5-1 1:30:30)
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
