【发布时间】:2013-06-09 13:47:12
【问题描述】:
我有这个代码:
$(".input_photo").click(function() {
$.post("ajax/imagefile.html", function(img){
complete: $(".bp_load").fadeIn(0).html(img);
});
});
Imagefile 是一个简单的 HTML 页面,其中包含 ID 为 imageform 的表单和输入类型文件。
我还有另一个代码:
$('#photoimg').live('change', function(){
$("#imageform").ajaxForm({
target: '.preview'
}).submit();
});
我在网上搜索,了解到live 已弃用,我已更改为on,但它不起作用。输入类型文件改变了,但没有触发事件。
【问题讨论】:
-
您使用的是哪个版本的 jQuery?您是否收到任何控制台错误?
-
你使用什么 jQuery 版本? $.on() 在 1.7 中添加。
-
据我所知,此事件似乎仅限于 元素。stackoverflow.com/questions/1443292/…
-
@user2465422 live() 已从 1.9.x 中删除,因此请使用 .on() 委托