Refreshing in Chrome

Refreshing in Chrome

Apologies if this is something asked before - I've tried several searches so far without success.

I have a page with a bunch of divs containing pictures with captions below and I used the following to make them all the size of the largest:

$(document).ready(function() {
        var maxHeight = 0;
        $(".photo-thumb").each(function(){
                if ($(this).height() > maxHeight) {
                        maxHeight = $(this).height();
                }
        });
        $(".photo-thumb").height(maxHeight);
});

In either Chrome or Firefox it behaves exactly as expected when I first load the page.  If I refresh the page (e.g. F5, "Reload current page", etc.) the script still functions as normal in Firefox.  If I refresh in Chrome the formatting is lost.

Any pointers would be appreciated.

Chris