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/htmlinputelement/multiple/index.html | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 files/zh-cn/web/api/htmlinputelement/multiple/index.html (limited to 'files/zh-cn/web/api/htmlinputelement/multiple/index.html') diff --git a/files/zh-cn/web/api/htmlinputelement/multiple/index.html b/files/zh-cn/web/api/htmlinputelement/multiple/index.html new file mode 100644 index 0000000000..937c52a93f --- /dev/null +++ b/files/zh-cn/web/api/htmlinputelement/multiple/index.html @@ -0,0 +1,44 @@ +--- +title: HTMLInputElement.multiple +slug: Web/API/HTMLInputElement/multiple +translation_of: Web/API/HTMLInputElement/multiple +--- +
{{ APIRef("HTML DOM") }}
+ +

HTMLInputElement.multiple 属性表示一个input是否可以有多个值。目前只有火狐支持 <input type="file">存有多个值。

+ +

实例

+ +
// fileInput is a <input type=file multiple>
+let fileInput = document.getElementById('myfileinput');
+
+if (fileInput.multiple == true) {
+
+  for (let i = 0; i < fileInput.files.length; i++) {
+    // Loop fileInput.files
+  }
+
+// Only one file available
+} else {
+  let file = fileInput.files.item(0);
+}
+
+ +

See also

+ + + +

Specification

+ + + +

Browser compatibility

+ + + +

{{Compat("api.HTMLInputElement.multiple")}}

-- cgit v1.2.3-54-g00ecf