Nabil
Nabil

Reputation: 175

jQuery: 100% height of THIS div

How do I use .height() to get height from .post and apply it to .left, each .post has different heights so I need to use this() I think, but can't find the solution... My jQuery only snaps the height from the first .post.

<div class="object">
    <div class="post">
        <div class="left">
        </div>
        <div class="right">
            <p>Lorem ipsum dolar sit amet</p>
        </div>
    </div>
</div>

$(document).ready(function(){
    $height = $('.object .post').height();
    $final = $height-53
    $('.object .post .left').css({
        height: $final
    });
});

Upvotes: 2

Views: 88

Answers (2)

FiLeVeR10
FiLeVeR10

Reputation: 2165

or just use css

.post{position:relative}
.left{position:absolute;top:0;left:0;height:100%}

made a fiddle: http://jsfiddle.net/filever10/rzFhL/

Upvotes: 0

dfsq
dfsq

Reputation: 193261

Something like this:

$(document).ready(function() {
    $('.left').height(function() {
        return $(this).parent().height() - 53;
    });
});

This will set the height of each .left div to its corresponding parent .post minus 53px.

Upvotes: 3

Related Questions