Internet Explorer不支持< input type =“file”/>的多个属性.然而,它不仅缺乏这种支持的IE ……某些移动浏览器也不支持多属性.因此,简单地检测浏览器是IE不是理想的解决方案.
那么我如何检测< input type =“file”/>是否支持multiple属性?用JavaScript?
UPDATE
http://modernizr.com/docs/#input
然而,接受的解决方案似乎有效,因为我已经在使用Modernizr,我的解决方案如下:
/** * Determines if the given attribute is supported for <input /> elements. * * @param attribute - the attribute to test for (ex. "multiple") */ function isInputAttributeSupported(attribute) { return (Modernizr.input[attribute]) ? true : false; };
解决方法
var inp = document.createElement("input"); inp.setAttribute("multiple","true"); var supportsMultiple = inp.multiple===true;
原文地址:https://www.jb51.cc/js/159508.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。