jq为例: $('body').on('click', "#Download",function(){//点击下载按钮 let triggerDelay = 100; let removeDelay = 1000; let url_arr=[]; //多个file文件选择checkbox $('input[name="filePath"]:checked').each(function(){ url_arr.push($(this).val());//取到下载url }); url_arr.forEach(function(item,index){ _createIFrame(item, index * triggerDelay, removeDelay); }) function _createIFrame(url, triggerDelay, removeDelay) { //动态添加iframe,设置src,然后删除 setTimeout(function() { var frame = $('<iframe style="display: none;" class="multi-download"></iframe>'); frame.attr('src', url); $(document.body).after(frame); setTimeout(function() { frame.remove(); }, removeDelay); }, triggerDelay); } }
jq为例: