Jquery触发器文件输入 [英] Jquery trigger file input

查看:189
本文介绍了Jquery触发器文件输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用jQuery触发上传框(浏览按钮)。

我现在尝试的方法是:

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

$('#fileinput').trigger('click');   

但它似乎不工作。
请帮助。谢谢。

But it doesn't seem to work. Please help. Thank you.

推荐答案

这是由于安全限制。

< input type =file/> 设置为 display:none; / code>或 visbilty:hidden

I found out that the security restriction is only when the <input type="file"/> is set to display:none; or is visbilty:hidden.

所以我试图将其定位在视口外 position:absolute top:-100px; 和voilà工作。

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

请参阅 http://jsfiddle.net/DSARd/1/

称为黑客。

希望对你有用。

这篇关于Jquery触发器文件输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆