Wasim Shaikh
Wasim Shaikh

Reputation: 7030

Height of the div respective to other DIV

Hi I have DIV structure something like this.

<div class="leftCol">
   Left Col Content
</div>

<div class="rightCol">
   Right Col Content
</div>

I want to calculate the height of the right col. and that height to Left col.

Upvotes: 0

Views: 101

Answers (2)

DannyLane
DannyLane

Reputation: 2096

var leftHeight = $(".leftCol").height();
var rightHeight = $(".rightCol").height();

var diff = leftHeight - rightHeight;

More info here

Upvotes: 0

OneSHOT
OneSHOT

Reputation: 6953

I presume you want to set the left columns height the same as the right one! if so this would work.

$(".leftCol").height($(".rightCol").height());

Although you would only want to do this when the DOM is ready so it would be wise to only execute the code when the page is fully loaded or the column resizes.

$(function() {
    $(".leftCol").height($(".rightCol").height());
});

HTH

Upvotes: 1

Related Questions