My first question is: why are you using max-height: 0; Is there anything else you can use? Like hide() show() that use display: none
The only thing I can do is remove the max-height css, get the height, and then reuse max-height:
$('.div').css('max-height', 'none') console.log($('.div').height()) $('.div').css('max-height', '0')
This should happen fast enough so you don't see the element, but it would be wise to hide it before removing max-height with
$('.div').hide() $('.div').css('max-height', 'none') console.log($('.div').height()) $('.div').css('max-height', '0') $('.div').show()
source share