weixin_33690963 2015-12-04 14:20 采纳率: 0%
浏览 4

加载后的图像高度()

I'm having this problem:

$('#ajax-div').load(page, function(){ 
    alert(jQuery('#ajax-div img').outerHeight());
});

The first time I load the alert says = 0.

If I load again it gets the correct height.

How can I resolve this first load problem?

  • 写回答

1条回答 默认 最新

  • weixin_33734785 2015-12-04 14:24
    关注

    Make sure that the image is loaded before you call:

    $('#ajax-div').load(page, function() {
        jQuery('#ajax-div img').load(function () {
            alert(jQuery(this).outerHeight());
        });
    });
    

    More Info: Look on the Caveats section in .load().

    评论

报告相同问题?