0

The question is about $("#id").click(); when document loads. *** here I don't want to assign or attach a .on("click") but actually clicking the input...

Goal, when user arrive to upload section, open the input file right away (reducing steps for the user to send images, videos, etc)

I have this code

<input type="file" ... id="input_ID" >
<script> $( document ).ready(function() { $("#input_ID").click(); }); </script>

console log says something about file chooser dialog can only be shown with a user action...

is there a way to do the .click on page load ??

Regards

Jintor
  • 607
  • 8
  • 32
  • "console log says something about file chooser dialog can only be shown with a user action..." there's your answer. Clicks can be triggered on page load, except for those which require user action, like those on an `input type="file"`. – Heretic Monkey May 28 '20 at 16:34
  • 1
    Does this answer your question? [In JavaScript can I make a "click" event fire programmatically for a file input element?](https://stackoverflow.com/questions/210643/in-javascript-can-i-make-a-click-event-fire-programmatically-for-a-file-input) – Heretic Monkey May 28 '20 at 16:35
  • use `input.trigger("click");` – ROOT May 28 '20 at 16:35
  • Why don't you just put your code which you want to invoke after click, inside $(document).ready(function() {})? – Sa1m0n May 28 '20 at 16:35
  • https://stackoverflow.com/questions/210643/in-javascript-can-i-make-a-click-event-fire-programmatically-for-a-file-input – Negi Rox May 28 '20 at 17:36

0 Answers0