Skip to content

Instantly share code, notes, and snippets.

@bgaeddert
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save bgaeddert/3ac60fb2813ee8766ade to your computer and use it in GitHub Desktop.

Select an option

Save bgaeddert/3ac60fb2813ee8766ade to your computer and use it in GitHub Desktop.

Revisions

  1. bgaeddert renamed this gist May 28, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. bgaeddert created this gist Feb 17, 2015.
    19 changes: 19 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    // For use with jQuery
    // Example
    equalize_heights('.row .box')
    // This will make all the .box elements the same height.

    function equalize_heights(elem){
    // Get an array of all element heights
    var elementHeights = $(elem).map(function() {
    return $(this).height();
    }).get();

    // Math.max takes a variable number of arguments
    // `apply` is equivalent to passing each height as an argument
    var maxHeight = Math.max.apply(null, elementHeights);

    // Set each height to the max height
    $(elem).height(maxHeight);
    return $(elem);
    }