Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery set height of element

Tags:

jquery

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 );

});
like image 417
cusejuice Avatar asked Dec 13 '25 15:12

cusejuice


1 Answers

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() );
});
like image 137
VisioN Avatar answered Dec 15 '25 09:12

VisioN