Emulate a file upload click in jQuery

后端 未结 4 1362
悲&欢浪女
悲&欢浪女 2020-12-17 00:55

I have an tag that I have bound a click event to in jQuery. When it is clicked I\'d like to have it emulate the click of a button on the file

4条回答
  •  长情又很酷
    2020-12-17 01:36

    Just wrap the img in a label and set the for attribute to the file input. Works for any kind of content and it's built into the spec. You can even hide the file input at that point.


提交回复
热议问题