Skip to content

Instantly share code, notes, and snippets.

@jdcauley
Last active April 26, 2016 20:26
Show Gist options
  • Save jdcauley/e8a96ca044f0e83a844b22f447d50ee8 to your computer and use it in GitHub Desktop.
Save jdcauley/e8a96ca044f0e83a844b22f447d50ee8 to your computer and use it in GitHub Desktop.
MatchBox.js
(function ($, undefined) {
$.fn.matchBox = function () {
var Boxes = this,
tallest = 0,
height;
Boxes.each(function(i){
height = $(this).height();
if(height > tallest){
tallest = height;
}
});
Boxes.height(tallest);
}
})(jQuery);
function matchBox(elements){
var Boxes = elements,
tallest = 0,
height;
for(var i = 0, x = boxes.length; i < x; i++){
}
Boxes.each(function(i){
height = $(this).height();
if(height > tallest){
tallest = height;
}
});
Boxes.height(tallest);
}
}
matchBox(document.getElementsByClassName('js-matchbox'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment