Trigger file input dialog

前端 未结 8 2045
忘了有多久
忘了有多久 2021-02-13 04:31

How can I auto trigger file input? ie. in the link below I want to trigger upload button on load

DEMO

8条回答
  •  执笔经年
    2021-02-13 05:04

    The problem with your code is that you are applying a click event to the input and also to the div enclosing the button, but not to the actual button.

    if you change your fiddle to this

    
      
          

    and

    $("#test1 button").trigger('click');
    

    then the click trigger will be applied to the button. Alternatively give your button an ID and fo

    $("#buttonid").trigger('click');
    

提交回复
热议问题