Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  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('.main article');
  34. });
  35.  
  36.  
  37. $(window).resize(function(){
  38. equalheight('.main article');
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement