Can I trigger a double click with a single click in a form input[type="file"]?
css, javascript, jquery
Solution
The answer isn't to trigger a dblclick, but to make file dialog opening with IE... Right? So i think the soluce would be to trigger a click on the file input (wich will be hidden?)
$("#formId").find("input[type='file']").trigger('click');
In your fiddle, I do this :
$("input").click(function() {
$('input[type="file"]').click();
});
I try this
$('input[type="file"]').hide().parent().append($('<span />').attr('class', 'filebutton').text('Upload'));
$(".filebutton").click(function() {
$('input[type="file"]').click();
});
With this CSS
form {
color:#666;
}
.filebutton {
content:'upload';
font:small-caps 15px Georgia;
letter-spacing:1px;
border-radius:10px;
border:1px solid #eee;
width:100px;
padding:10px;
margin:20px;
text-align:center;
position:absolute;
left:0;
top:0;
z-index:1;
background-color:#f8f8f8;
}
.filebutton:hover {
background-color:#f3f3f3!important;
color:#c00;
cursor : pointer;
}
And it work's...
Problem
I have a form `input` for submitting a file and I styled it because I didn't like the native style. Now, I have a single button that when clicked, it opens up the dialog to select the file. It works fine with a single click on Firefox and Chrome but it doesn't work in IE. The button needs a double click to open up the dialog in IE. I have tried to trigger a double click with a single click using jQuery: ``` $("input").click(function() { $(this).dblclick(); }); ``` However, it doesn't seem to work. Is there any other approach to trigger a double click for IE? Here's the demo: http://jsfiddle.net/HAaFb/