HTMLInputElement.multiple

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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
multipleChrome Full support YesEdge Full support 12Firefox Full support 3.6IE ? Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown