Skip to content

Instantly share code, notes, and snippets.

@greg-randall
Created December 17, 2021 13:28
Show Gist options
  • Select an option

  • Save greg-randall/0a5d5cbb79d8c5b276a363836204b318 to your computer and use it in GitHub Desktop.

Select an option

Save greg-randall/0a5d5cbb79d8c5b276a363836204b318 to your computer and use it in GitHub Desktop.
Make some boxes on a website the same height. Add a common class name to the boxes, and swap out your class name for ".class-name-of-box". Requires jQuery.
<script>
function equalHeight(group) {
var tallest = 0;
group.each(function() {
var thisHeight = $(this).height();
if(thisHeight > tallest) {
tallest = thisHeight;
}
});
group.height(tallest);
}
$(document).ready(function() {
equalHeight($(".class-name-of-box"));
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment