jQuery 中的 Javascript .files[0] 属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11443886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Javascript .files[0] attribute in jQuery
提问by bento
Is there an equivalent to this statement in jQuery?
jQuery 中是否有与此语句等效的语句?
var value = document.getElementById(id).files[0];
Using the standard jQuery selectors with .files[0] appended doesn't appear to work, and I can't find an equivalent jQuery command to .files. Any suggestions?
使用附加了 .files[0] 的标准 jQuery 选择器似乎不起作用,而且我找不到与 .files 等效的 jQuery 命令。有什么建议?
I'm using this to retrieve the file from an input type='file' form element.
我正在使用它从输入 type='file' 表单元素中检索文件。
回答by Trinh Hoang Nhu
$('#id').get(0).files[0]
get(0) return DOM element
get(0) 返回 DOM 元素