(function($) { "use strict"; function equalHeight(){ // EQUAL HEIGHT on large screen size $('.equal-height-container-large').each(function(){ if($(window).width() > 960) { var highestBox = 0; $('.equal-height-item', this).each(function(){ if($(this).height() > highestBox) { highestBox = $(this).height(); } }); $('.equal-height-item',this).height(highestBox); } else { $('.equal-height-item', this).each(function(){ $(this).css('height', ''); console.log('window small'); }); } }); } $(document).ready(equalHeight); $(window).resize(equalHeight); })(jQuery);