renat natanael
renat natanael

Reputation: 137

need to reload for jquery to do the function

i have a code for check every height's thumbnail and make all thumbnail to have the height of the tallest thumbnail. its work well for the first time. then i test it in resolution 768x163 from 1440x613 all my thumbnail seems like have a little space inside the caption. so i try to reload the page. and the bug got fix. so how to make the function to work when i minimize the window without have to reload the page

this my code on height.js

    (function($) {
    "use strict";

    // THUMBNAIL HEIGHT
    function equalHeight(group) {    
        var tallest = 0;    
        group.each(function() {       
            var thisHeight = $(this).height();       
            if(thisHeight > tallest) {          
                tallest = thisHeight;       
            }    
        });    
    group.each(function() { $(this).height(tallest); });
    } 

    $(document).ready(function() {   
      equalHeight($(".thumbnail")); 
    });
})(jQuery); 

heres jsfiddle https://jsfiddle.net/nr2cc6LL/

Upvotes: 0

Views: 65

Answers (1)

palaѕн
palaѕн

Reputation: 73906

Just call the function inside the resize method too like:

$(window).resize(function() {
    equalHeight($(".thumbnail"));
});

Simple Demo

Upvotes: 4

Related Questions