使用jQuery打开文件浏览器 [英] open file browser using jquery
本文介绍了使用jQuery打开文件浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
<p onclick="jQuery('#file').click()">Select a file</p>
<input type="file" id="file" name="file" />
当用户单击选择文件"时,也应该打开文件浏览器,就像您按<input type="file" />
生成的浏览"按钮时一样,用户可以在其中选择文件.
When the user clicks on "Select a file", it's also supposed to open the file browser like when you press on the "Browse" button generated by <input type="file" />
, where the user can select a file.
它在Chrome和IE7中正常运行.如何使其在Firefox中工作?
It works fine in Chrome and IE7. How do I make it work in Firefox?
推荐答案
有一种更好的方法来打开对话框(目前,该对话框可在所有现代浏览器中使用).只是改变
There is a better way to open the dialog (it works across all modern browsers at this time). Just change
jQuery('#file').click();
到
jQuery('#file').trigger('click');
这篇关于使用jQuery打开文件浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文