Test case details

Preparation Code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <div id="div1"></div> <script> var currentDiv = document.getElementById("div1"); for (var x=1000; x--;){    var newDiv = document.createElement("div");    newDiv.style.height = Math.floor(Math.random()*10)+ 'px';    currentDiv.appendChild(newDiv); } var totalHeight = 0; </script>

Test cases

Test #1

$("#div1").children().filter(':visible').each(function(){     totalHeight += $(this).outerHeight(); }); console.log('totalHeight');

Test #2

currentDiv.style.display = "none";             currentDiv.height = 'auto';             totalHeight += currentDiv.height;             currentDiv.height = 0 + 'px';             currentDiv.style.display = "block";             console.log(totalHeight)