HTMLInputElement.multiple

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

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

实例

js
// 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

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
multiple

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support