Skip to content

Instantly share code, notes, and snippets.

@mperlet
Created December 17, 2020 07:28
Show Gist options
  • Save mperlet/6afe3b0d2c015f8b793eed707661c8e3 to your computer and use it in GitHub Desktop.
Save mperlet/6afe3b0d2c015f8b793eed707661c8e3 to your computer and use it in GitHub Desktop.
jQuery calculate parent height by sum up childrens height
var parentHeight = $.map($('.parent > *'), function (i) {
return ($(i).height())
}).reduce(function (accumulator, currentValue) {
return accumulator + currentValue;
}, 0);
$('.parent').height(parentHeight);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment