Javascript .files[0] attribute in jQuery

倾然丶 夕夏残阳落幕 提交于 2019-12-09 19:07:04

问题


Is there an equivalent to this statement in 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?

I'm using this to retrieve the file from an input type='file' form element.


回答1:


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

get(0) return DOM element



来源:https://stackoverflow.com/questions/11443886/javascript-files0-attribute-in-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!