From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/htmloptionelement/option/index.html | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 files/zh-cn/web/api/htmloptionelement/option/index.html (limited to 'files/zh-cn/web/api/htmloptionelement/option') diff --git a/files/zh-cn/web/api/htmloptionelement/option/index.html b/files/zh-cn/web/api/htmloptionelement/option/index.html new file mode 100644 index 0000000000..c00336924d --- /dev/null +++ b/files/zh-cn/web/api/htmloptionelement/option/index.html @@ -0,0 +1,47 @@ +--- +title: Option() +slug: Web/API/HTMLOptionElement/Option +tags: + - API + - HTML DOM + - HTMLOptionElement +translation_of: Web/API/HTMLOptionElement/Option +--- +

{{APIRef("HTML DOM")}}

+ +

用于创建{{domxref("HTMLOptionElement")}}的构造函数。

+ +

句法

+ +
var optionElementReference = new Option(text, value, defaultSelected, selected);
+ +

参数

+ +
+
文字{{optional_inline}}
+
表示元素内容的{{domxref("DOMString")}},即显示的文本。如果没有指定,则使用默认值""(空字符串)。
+
值{{optional_inline}}
+
表示{{domxref("HTMLOptionElement")}}的值的{{domxref("DOMString")}},即value等价的{{htmlelement("option")}} 属性。如果未指定,则将文本的值用作值,例如,将表单提交给服务器时,相关联的{{htmlelement("select")}}元素的值。
+
defaultSelected {{optional_inline}}
+
设置{{htmlattrxref("selected", "option")}}属性值的{{domxref("Boolean")}},也就是说这个{{htmlelement("option")}}是默认值当第一次加载页面时,在{{htmlelement("select")}}元素中选择。如果没有指定,false则使用默认值请注意,true 如果选项尚未被选中,则该值不会将选项设置为选中状态。 
+
选中{{optional_inline}}
+
A {{domxref("Boolean")}}设置选项的选择状态; 默认是false(未选中)。如果省略,即使defaultSelected参数是true,该选项没有被选中。
+
+ +

规范

+ + + + + + + + + + + + + + +
规范状态评论
HTML5
+ 该规范中"选项"的定义。
建议 
-- cgit v1.2.3-54-g00ecf