javascript - Calling "Click()" method of an element returns undefined, although the element definitely exists -
this question has answer here:
i'm trying call click() method of file input specific id, function call returns undefined , basically, nothing happens. i've replicated situation here: http://jsfiddle.net/gkag2/
it's simple:
html
<input id="hiddenfileinput" type="file" multiple="multiple" accept="image/*" >
javascript
document.getelementbyid('hiddenfileinput').click(); alert(document.getelementbyid('hiddenfileinput').click());
i try calling click() method on element, doesn't work. call alert() print function returns when it's called. returns "undefined." i'm doing wrong, exactly?
you can't emulate click on input type=file
. it's forbidden. works inside onclick handler. user must click on open dialog.
Comments
Post a Comment