如何在jQuery中输入type = file处理onchange事件? [英] How to handle onchange event on input type=file in jQuery?
本文介绍了如何在jQuery中输入type = file处理onchange事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码是:
<input ID="fileUpload1" runat="server" type="file"
以下工作正常:
<input onchange="javascript:alert('hola');" ID="fileUpload1" runat="server" type="file"
我想要这个结果使用jQuery,但是这不行:
I'd like to get this result using jQuery, but that doesn't work:
$('#fileUpload1').change(function (e) {
alert("hola");
});
我错过了什么? (编辑:是的,我错过了* .js文件。)
I am missing something? ( Yes I missed include the *.js file.)
推荐答案
演示: http://jsfiddle.net/NbGBj/
$("document").ready(function(){
$("#upload").change(function() {
alert('changed!');
});
});
这篇关于如何在jQuery中输入type = file处理onchange事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文