tags:

views:

40

answers:

2

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.

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

var diff = leftHeight - rightHeight;

More info here

DannyLane
$("leftCol") would look for tags rather than classes if your selecting elements based on a class you need to prefix the class name with a "." (dot) if you are selecting by ID you need to prefix with a "#" (hash). You would generally use a selector with neither to select all tags of a specific type eg $('div')
OneSHOT
You're right, i forgot the ".", thanks for the heads up.
DannyLane
+1  A: 

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

OneSHOT
thanks .. it does helps
Wazdesign