Remove a FileList item from a multiple quot;input:filequot;(从多个“input:file中删除 FileList 项)
问题描述
我有这个 DOM:
var id = 0;
$('input:file#upload')[0].files[ id ]
这是第 0 个索引上的第一个文件.列出了文件属性并且一切正常,但是...
That get's the first file on the 0th index. File properties are listed and all works, but...
我们如何使用 JavaScript 从 DOM 的 [object FileList]
中删除项目?
How do we remove items from the DOM's [object FileList]
with JavaScript?
推荐答案
恐怕不能直接从 FileList object
中删除对象.只需将 $('input:file#upload')[0].files
分配给 Array
然后使用 splice
从该数组中删除项目或您选择的方法,然后使用该 Array
.
I' am afraid that you cannot delete objects from FileList object
directly. Just assign $('input:file#upload')[0].files
to an Array
and then remove items from that array using splice
or method of your choice and then use that Array
.
这篇关于从多个“input:file"中删除 FileList 项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从多个“input:file"中删除 FileList 项


基础教程推荐
- 直接将值设置为滑块 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01