Execute a function after all images within a div loaded

Viewed 2450

I want to get height of a div with jQuery and in this div, there is some images that change the size of this div when loaded:

but with code below, it gives me height of div before images were loaded

$(document).ready(function() {
        $(".link_module").each(
            function () {
                maxheight = Math.max(maxheight,$(this).height());
            }
        ).height(maxheight);
});

I've changed my code to this but nothing change:

$(document).ready(function() {
    $(".link_module img").load(
        function (){
            $(".link_module").each(
                function () {
                    maxheight = Math.max(maxheight,$(this).height());
                }
            ).height(maxheight);
        }
    )
});

Can anyone help me change the code to reach my goal?

3 Answers
Related