jQuery trigger file input

后端 未结 21 1615
梦如初夏
梦如初夏 2020-11-22 08:49

Am trying to trigger an upload box (browse button) using jQuery.
The method I have tried now is:

$(\'#fileinput\').trigger(\'click\');   
21条回答
  •  旧时难觅i
    2020-11-22 09:03

    This is due to a security restriction.

    I found out that the security restriction is only when the is set to display:none; or is visbilty:hidden.

    So i tried positioning it outside the viewport by setting position:absolute and top:-100px; and voilà it works.

    see http://jsfiddle.net/DSARd/1/

    call it a hack.

    Hope that works for you.

提交回复
热议问题