jQuery 中的 Javascript .files[0] 属性

标签 javascript jquery multipartform-data

在 jQuery 中是否有与此语句等效的语句?

var value = document.getElementById(id).files[0];

使用附加了 .files[0] 的标准 jQuery 选择器似乎不起作用,而且我找不到与 .files 等效的 jQuery 命令。有什么建议么?

我正在使用它从 input type='file' 表单元素中检索文件。

最佳答案

$('#id').get(0).files[0]

get(0) 返回 DOM 元素

关于jQuery 中的 Javascript .files[0] 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11443886/

相关文章:

javascript - Bootstrap 4轮播循环方法

javascript - 将不同宽高比的图像均匀地放入多行

java - Spring Rest 返回 multipart/form-data 和 application/json 内容类型

javascript - 在 Google map 中推送新的 LatLng

javascript - 在使用 bitcoinjs-lib 时,我得到 getAddress() is not function

javascript - 无法使 div/元素在嵌套的 shadowdom 中移动

ios - 无法使用 Swift 上的多部分请求将图像上传到 Paperclip

javascript - 如何获取第 X 个最近的 SQL 查询

javascript - 使用 html2canvas 将 HTML 表格转换为 Canvas

javascript - 如何在 javascript 的 FormData 中追加对象?