$(window).load(function(){ $stBody = $('.st-body'); function setStory(){ var w = $(window).width(); $stBody.find('.st-dtl .st-in').removeAttr('style'); if(w >= 600){ $stBody.each(function(){ var hei = 0; $(this).find('.st-dtl').each(function(){ var thisH = $(this).find('.st-in').height(); if(thisH >= hei){ hei = thisH; } }); $(this).find('.st-dtl .st-in').css({'height': hei}); }); }else{ $(this).find('.st-dtl .st-in').css({'height': 'auto'}); } } $(window).resize(function(){ setStory(); }); setStory(); });