DIV等高JS控制

时间:2022-08-25 12:23:26

 

DIV等高JS控制DIV等高JS控制代码
window.onload  =   function ()
{
     
var  prodcut  =  document.getElementById( " productDIV " )getElementsByTagName( " div " );
     
var  len  =  prodcut.length;
     
var  h1;
     
var  h2;
     
for ( var  i = 0 ;i < len;i ++ )
     {
         
var  a = i;
         
var  b =++ i;
         
if (h1 < h2)
         {
            product[a].style.height
= h2 + " px " ;
         }
         
else
         {
            product[b].style.height
= h1 + " px " ;
         }
     }
}

HTML结构

<DIV id="product">

<div>faslkdjfkas

</div>

<div>124321342342</div>

</div>

 

 

写上怕忘记