Skip to content Skip to sidebar Skip to footer

Trigger Click Event Not Working In IE10

I need to add onclick event to an image so when I click on the image it will trigger the file open dialog. But it doesn't work in IE10.

Solution 1:

Ok, I tested this in the newest FF, Opera, Chrome, IE8, IE9, IE10, IE11. Its working everywhere.

HTML:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type="file" />
<img id="button" src="http://www.kafkabrigade.org.uk/wp-content/uploads/2011/07/button-pic.jpg" />

jQuery:

$('#button').click(function() {
    $('input[type=file]').trigger('click');
});

$('input[type=file]').change(function() {
    $('input[type=text]').val($(this).val());
});

CSS:

input[type=file] {
    display: block;
    height: 0;
    width: 0;
}

Working DEMO


Solution 2:


Post a Comment for "Trigger Click Event Not Working In IE10"