how would I detect if “multiple” attribute is supported for file input elements?

后端 未结 2 1739
南旧
南旧 2021-01-12 02:26

Internet Explorer does not support the multiple attribute for . However, its not only IE that lacks this support... al

相关标签:
2条回答
  • 2021-01-12 02:43
    var inp = document.createElement("input");
    inp.setAttribute("multiple", "true");
    var supportsMultiple = inp.multiple===true;
    
    0 讨论(0)
  • 2021-01-12 03:00

    You can try checking for the existence of the corresponding property:

    var supportsMultipleFiles = 'multiple' in document.createElement('input');
    

    Example: http://jsfiddle.net/sbZvS/

    0 讨论(0)
提交回复
热议问题