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 2015年7月.
HTMLInputElement.multiple プロパティは、入力フィールドが複数の値を持つことができるかどうかを示します。 Firefox では、 multiple は <input type="file"> でのみ対応しています。
値
論理値です。
例
js
// fileInput は <input type=file multiple> です
let fileInput = document.getElementById("myfileinput");
if (fileInput.multiple) {
  // fileInput.files を反復処理
  for (const file of fileInput.files) {
    // ファイルの一つに対してアクションを実行
  }
  // 一つのファイルのみが有効な場合
} else {
  let [file] = fileInput.files;
}
仕様書
| Specification | 
|---|
| HTML> # dom-input-multiple> | 
ブラウザーの互換性
Loading…
関連情報
- FileList
- Bug 523771 - <input type=file multiple> への対応