在页面加载jQuery后匹配div高度

Luk*_*asz 1 jquery height image match

加载图像后,我无法匹配div的高度.它获得了最高div的高度,但它似乎在图像加载之前得到它.有没有办法解决?这是我到目前为止:

function matchColHeights(col1, col2) {
    var col1Height = $(col1).height();
    alert('col1 '+col1Height);
    var col2Height = $(col2).height();
    alert('col2 '+col2Height);

    if (col1Height < col2Height) {
        $(col1).height(col2Height);

    } else {
        $(col2).height(col1Height);
    }
}

$(document).ready(function() {
    matchColHeights('#leftPanel', '#rightPanel');
});
Run Code Online (Sandbox Code Playgroud)

这是一个链接到它的运行位置:http://www.tigerstudiodesign.com/blog/

Lei*_*ski 5

加载图像后,列高是否调整大小.就像是:

$('img').load(function() {
     $(col1).height(col2Height);
});
Run Code Online (Sandbox Code Playgroud)