SHARE
TWEET

Untitled

a guest Feb 17th, 2017 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. equalheight = function(container){
  2.  
  3. var currentTallest = 0,
  4.      currentRowStart = 0,
  5.      rowDivs = new Array(),
  6.      $el,
  7.      topPosition = 0;
  8.  $(container).each(function() {
  9.  
  10.    $el = $(this);
  11.    $($el).height('auto')
  12.    topPostion = $el.position().top;
  13.  
  14.    if (currentRowStart != topPostion) {
  15.      for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
  16.        rowDivs[currentDiv].height(currentTallest);
  17.      }
  18.      rowDivs.length = 0; // empty the array
  19.      currentRowStart = topPostion;
  20.      currentTallest = $el.height();
  21.      rowDivs.push($el);
  22.    } else {
  23.      rowDivs.push($el);
  24.      currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
  25.   }
  26.    for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
  27.      rowDivs[currentDiv].height(currentTallest);
  28.    }
  29.  });
  30. }
  31.  
  32. $(window).load(function() {
  33.   equalheight('.bp');
  34. });
  35.  
  36.  
  37. $(window).resize(function(){
  38.   equalheight('.bp');
  39. });
RAW Paste Data
Top