Make DIVs the same height

dextermorgan
dextermorgan used Ask the Experts™
on
I have 2 divs - both with the same class that gives them a min-height. What i want to do is to use javascript/jquery to check the height of DIV B and change the min height in the class.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
document.getElementById('divb').style.height = document.getElementById('diva').style.height;

divb, diva are id's of the div's

-Ajitha
if there is a class 'divclass' which has the min-height property, then following code will change a property of a class.

setClassStyle( 0, "divclass", "min-height", document.getElementById("divB").height);
function setClassStyle(s_s,classname,class_style,style_valu e)
{
	var style_sheet=document.styleSheets[s_s];
	for (var j=style_sheet.rules.length-1;j>=0;j--)
	{
		var sS=style_sheet.rules[j];
		var class_name=sS.selectorText.replace(/\./g,'');
		if(class_name==classname)
		{
			sS.style[class_style]=style_value;
			return 0;
		}
	}
}

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial