Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. // Search for rows in document with jQuery and equalize height
  2. function windowResizeCallback() {
  3. $('.row').each(function() {
  4. equalizeHeight($(this));
  5. });
  6. }
  7.  
  8. // Looks for elements with 'eq-height' class and set to maximum height all of them
  9. function equalizeHeight(row) {
  10. var elems = row.find('.eq-height');
  11.  
  12. if (elems.length < 2) { return; }
  13.  
  14. elems.css('height','');
  15.  
  16. var h_max = elems.height();
  17.  
  18. elems.each(function() {
  19. h_max = $(this).height() > h_max ? $(this).height() : h_max;
  20. });
  21.  
  22. elems.css('height', h_max);
  23. }
  24.  
  25. // Call it on resize, just in case
  26. window.onresize = windowResizeCallback;
  27. windowResizeCallback();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement