How do I get the height and width of a div.
My divs's height and width is set to auto so it scales up or down depending on the size of its content at diffrent device screen sizes. How do I get the div's height at any point in time on any device.
var x = document.getElementById('div-id').clientHeight var y = document.getElementById("div-id").clientWidth console.log('div height', x) console.log('div width', y)
Whereby "div-id" is the id of the div whose height you wish to know. You can replace it with your own custom id.
The "clientHeight" gets the specific height of the div with id of "div-id".
The "clientWidth" gets the specific width of the div with id of "div-id".
Click on the button below to add a new message to this thread
Satus: OpenMessages: 1Started: 2022-03-31
Click the button below to start a new thread for your question
By using our website,