How to calculate div height with definition of 'height = auto'

I need to calculate the height of this div with Javascript.

When I wrote this script:

function getMainDivHeight() {
    var num = document.getElementById('up_container').style.height;
    return num;
}

this script returns auto

I need the height of the div after changing it.

Thank!!

+3
source share
1 answer

You need to get the property offsetHeight:

function getMainDivHeight() { 
 var num = document.getElementById('up_container').offsetHeight; 
 return num; 
}
+5
source

All Articles