How can i get the same functionality as this .each() using a for loop? <p>I have written this function to assign line-height to elements with different heights.Is there any possible way of doing this using a for loop ?</p> <pre><code>$(".portfolio-image-overlay").each(function(){ "use strict"; var height = $(this).siblings("img").height(); var cheight = $(".item.active&gt; a&gt; img").height(); $(this).css({"line-height":height+"px"}); $(this).css({"line-height":cheight+"px"}); }); </code></pre>