javascript 等高行javascript

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 等高行javascript相关的知识,希望对你有一定的参考价值。

    equalheight = function(container){
        var currentTallest = 0,
             currentRowStart = 0,
             rowDivs = new Array(),
             $el,
             topPosition = 0;
             jQuery(container).each(function() {
           $el = jQuery(this);
           jQuery($el).height('auto')
           topPostion = $el.position().top;

           if (currentRowStart != topPostion) {
             for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
        
               rowDivs[currentDiv].height(currentTallest);

             }
             rowDivs.length = 0; // empty the array
             currentRowStart = topPostion;
             currentTallest = $el.height();
             rowDivs.push($el);
           } else {
             rowDivs.push($el);
             currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
          }
           for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
             rowDivs[currentDiv].height(currentTallest);
           }
         });
        }

        equalheight('.brand-name');
        equalheight('.product__heading');
        equalheight('.price-box');
        equalheight('.product');
        equalheight('.product-list-item');

以上是关于javascript 等高行javascript的主要内容,如果未能解决你的问题,请参考以下文章