jQuery .load method not firing on IE9

我怕爱的太早我们不能终老 提交于 2019-12-17 21:22:17

问题


I have 4 divs (class=mydiv), each with an image in, the load method fires on all other browsers I've tested but it does not fire on IE9.0. I don't know if it works in any other IE.

$.noConflict();

jQuery(document).ready(function(){

    jQuery('.mydiv img').load(function(){

        alert("fired");

    });

});

Tried using these jQuery versions:

1.4.2
1.5.2
1.6.2
1.5.1rc1


回答1:


I had the same problem and solved using:

if ($.browser.msie && parseInt($.browser.version) < 10) {
    window.onload = new function() {
        console.log('LOADED IE');
    }
} else {
    $(window).load(function(){
        console.log('LOADED');
    })
}



回答2:


According to Shankar Cabus, you can modify by:

if ($.browser.msie) { // For IE only
    $('.mydiv img').onload = new function() {
        alert("fired");
    }
} else {
    $('.mydiv img').load(function(){
        alert("fired");
    })
}

Since you want to do something after $('.mydiv img') loaded, but not window loaded. Hope this helps.



来源:https://stackoverflow.com/questions/6870830/jquery-load-method-not-firing-on-ie9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!