jQuery之$.support.xxx
下面这段代码来自jQuery-file-upload 9.19官方Demo
1 $(function () { 2 'use strict'; 3 // Change this to the location of your server-side upload handler: 4 var url = window.location.hostname === 'blueimp.github.io' ? 5 '//jquery-file-upload.appspot.com/' : 'server/php/'; 6 $('#fileupload').fileupload({ 7 url: url, 8 dataType: 'json', 9 done: function (e, data) { 10 $.each(data.result.files, function (index, file) { 11 $('<p/>').text(file.name).appendTo('#files'); 12 }); 13 }, 14 progressall: function (e, data) { 15 var progress = parseInt(data.loaded / data.total * 100, 10); 16 $('#progress .progress-bar').css( 17 'width', 18 progress + '%' 19 ); 20 } 21 }).prop('disabled', !$.support.fileInput) 22 .parent().addClass($.support.fileInput ? undefined : 'disabled'); 23 });
对应的HTML
<input id="fileupload" type="file" name="files[]" multiple>
jQuery.support 用于检查浏览器对各项特性的支持。检查项多达 27 个。经搜索,应该是时从jQuery 1.9 开始.
注意这里的字面值"fileInput",fileupload插件可以使用input标签的id值作为属性名指引所生成的jquery插件对象, 此编程模式待学习研究.