June 23, 201214 yr I have a code that is to match the height of two side by side div columns. The code I have does extend the shorter div however when its extended the two divs are not even as they should be any ideas how to fix this here is the code that I have. matchColumns=function(){ var divs,contDivs,maxHeight,divHeight,d; divs=document.getElementsByTagName('div'); contDivs=[]; maxHeight=0; for(var i=0;i<divs.length;i++){ if(/\bcolumn\b/.test(divs[i].className)){ d=divs[i]; contDivs[contDivs.length]=d; if(d.offsetHeight){ divHeight=d.offsetHeight; } else if(d.style.pixelHeight){ divHeight=d.style.pixelHeight; } maxHeight=Math.max(maxHeight,divHeight); } } for(var i=0;i<contDivs.length;i++){ contDivs[i].style.height=maxHeight + "px"; } } window.onload=function(){ if(document.getElementsByTagName){ matchColumns(); } } Edited June 24, 201214 yr by Renaissance-Design Please use the code button or tags to format your code.
Create an account or sign in to comment