jQuery: "change" event on file input element does not fire
by rudylattae
HTML
<input name="file" type="file" />
<a>Trigger upload externally</a>
CSS
a {background-color: yellow}
JavaScript
/*
Using the file input itself to select a file works fine
*/
$('input[name=file]').change(function() {
alert($(this).val());
});
/*
However, using another element to trigger the file selector
does not cause the "change" function to be triggered.
*/
$('a').click(function() {
$('input[name=file]').click();
});