3

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
  • I am afraid there isn't for now. Please see this post. Commented Jul 12, 2012 at 1:34

1 Answer 1

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

get(0) return DOM element

Sign up to request clarification or add additional context in comments.

2 Comments

It just an fyi so you can refine your answer. Edit and I will upvote :)
Thanks! I totally forgot about .get(0).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.