Reputation: 497
I have a number of position absolute parent divs and some child elements in each of them, they are not identical at all but they all have the same class "force-middle" What I want to do is to calculate the total height of each div's children and apply it to the parent div
what I have so far is this:
var total = 0;
$(".force-middle").each(function() {
$(this).children().each(function() {
total = total + $(this).outerHeight();
});
$(this).css({"height":total});
});
Thanks in advance
Upvotes: 0
Views: 37
Reputation: 336
initialize total variable each for a parent like this
var total = 0;
$(".force-middle").each(function() {
total = 0
$(this).children().each(function() {
total = total + $(this).outerHeight();
});
$(this).css({"height":total});
});
Upvotes: 1