无法点击输入类型=“文件”在Windows Safari浏览器 [英] Unable to click input type="file" in windows safari browser

查看:177
本文介绍了无法点击输入类型=“文件”在Windows Safari浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的html代码

 < input type =buttonid =btnvalue =UPLOAD /> 
< input id =fileuploadtype =filestyle =display:none; />

这里是jquery代码

 $('#btn')。click(); 
});

在Chrome浏览器和Windows中Safari浏览器可以正常工作,Safari浏览器不会执行任何操作。控制台错误。
这是 jsfiddle

解决方案使用下面的代码来隐藏输入文件,而不是使用 display:none;

  opacity:0; width:0px; height:0px; 


Here is my html code

<input type="button" id="btn" value="UPLOAD" />
<input id="fileupload" type="file" style="display:none;" />

here is jquery code

 $('#btn').click(function () {
            $('#fileupload').click();
        });

It works as expected in Chrome and in windows safari doesn't do any thing.And i checked no error in console. Here is a jsfiddle

解决方案

try hiding input file using the below code instead of display:none;

 opacity:0;width:0px;height:0px;

这篇关于无法点击输入类型=“文件”在Windows Safari浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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