img图片onload事件

 

window.onload事件是在页面dom元素加载完后执行,也就包括了img图片中src加载完成,那么img.onload 就不会执行了。

$("img").each(function () {
    var src = $(this).attr("src");
    $(this).attr("src","");
    $(this).get(0).onload = function () {
        alert($(this).attr("src"))
    }
    $(this).attr("src",src);
})

 

posted @ 2014-12-03 13:51  K13  阅读(4382)  评论(0编辑  收藏  举报