Stuff
...">

JQuery sets element height

How to set parent's inner div height using each () method?

<div class="box">
    <div class="inner">Stuff</div>
</div>
<div class="box">
    <div class="inner">Stuff</div>
</div>
<div class="box">
    <div class="inner">Stuff</div>
</div>
<div class="box">
    <div class="inner">Stuff</div>
</div>

This does not work:

$('.box').each(function(){
    var $this = $(this);
    var $inner = $this.find(".inner");
    $inner.height( $this.height );

});
+3
source share
1 answer

To get the height of an element, you should use the method height() :

$('.box').each(function(){
    var $this = $(this);
    var $inner = $this.find(".inner");
    $inner.height( $this.height() );
});
+6
source

All Articles