cusejuice
cusejuice

Reputation: 10681

jQuery set height of element

How do I set the inner div's height to it's parent using the 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 doesn't seem to work:

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

});

Upvotes: 3

Views: 7237

Answers (1)

VisioN
VisioN

Reputation: 145398

To get element's height you have to use method height():

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

Upvotes: 6

Related Questions