//oBoxs[i].style.left=oBoxs[index].style.left; 與oBoxs[i].style.left=oBoxs[index].offsetLeft+"px";為什么不等同
?? ??? ??? ?if(i<cols){
?? ??? ??? ??? ??? ?hArr.push(oBoxs[i].offsetHeight);
?? ??? ??? ??? ?}else{
?? ??? ??? ??? ??? ??? ?var minH=Math.min.apply(null,hArr);
?? ??? ??? ??? ??? ??? ?var index=getMinhIndex(hArr,minH);//封裝 找最小值的索引
?? ??? ??? ??? ??? ??? ?oBoxs[i].style.position="absolute";
?? ??? ??? ??? ??? ??? ?oBoxs[i].style.top=minH+"px";
?? ??? ??? ??? ??? ??? ?//oBoxs[i].style.left=oBoxs[index].style.left;
?? ??? ??? ??? ??? ??? ?oBoxs[i].style.left=oBoxs[index].offsetLeft+"px";
?? ??? ??? ??? ??? ??? ?hArr[index]+=oBoxs[i].offsetHeight;
?? ??? ??? ??? ??? ?}
?? ??? ?}
2016-06-15
LZ打log就知道這兩個的值不同。offsetLeft可以判斷一個物體的距父元素的左邊距離,輸出的是具體的數(shù)值;
而style.left是一個屬性,是你要賦值給他的,他本身是沒有值的,就像變量一樣,可以理解為他只是一個變量名字而已。