javascript - Unable to click input type="file" in windows safari browser - Stack Overflow

Here is my html code<input type="button" id="btn" value="UPLOAD" >

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

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

Share Improve this question asked Aug 30, 2013 at 10:56 iJadeiJade 23.9k58 gold badges160 silver badges250 bronze badges 1
  • 2 Does it work if the fileupload element isn't hidden? – Barmar Commented Aug 30, 2013 at 10:59
Add a ment  | 

2 Answers 2

Reset to default 12

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

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

You can also do:

input[type="file"] {
    visibility: hidden;
    position: absolute;
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743732754a4497720.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信