jQuery onchange无法在IE中使用文件

时间:2013-12-31 12:55:14

标签: javascript jquery ajax internet-explorer

以下是我想通过Ajax上传文件的示例代码,但在IE浏览器中,当我点击浏览器时它不起作用,那么它的工作是否正常呢?

$(document).ready(function() {
    $('#photoimg').live('change', function() {
        // $("#photoimg").bind('propertychange change', function(e) {
        $(this).blur();
        $("#thumbnail").html('');
        $("#thumbnail").html('<img src="assets_admin/images/loader.gif">');
        $("#imageform").ajaxForm({
            target: '#thumbnail'
        }).submit();
        //setTimeout ("empty_image()",10000);
    });
});

2 个答案:

答案 0 :(得分:1)

$ .live()不支持更改事件:

目前不支持:模糊,焦点,鼠标中心,鼠标移动,更改,提交http://docs.jquery.com/Events/live

使用委托代替现场。

  $('div.facet_dropdown select').delegate('change', function() { ... });

答案 1 :(得分:0)

实际上,IE,特别是IE7 / 8并不能很好地支持onchange事件。我建议你使用onclick事件。

根据MSDN,

onchange事件不会在IE中冒泡。

Scott Leberknight on onChange http://www.nofluffjuststuff.com/blog/scott_leberknight/2005/04/onclick_versus_onchange_in_ie_and_firefox