 <p>This must work for you</p> <pre><code>var resizeEntryHeight=function(){ $('.collectionPostContainer').each(function(){ $(this).css('height',$(this).width()+'px'); }); } $(document).ready(function(){ resizeEntryHeight(); $(window).resize(resizeEntryHeight()); }); </code></pre>