Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the height of a div

<span style="width:100%" id="learning_menu"><div id="aLM" style="width:100%;height:100%">test | test | test</div></span>

The code above is the current HTML that I have. I'll be making the inner "div" shrink-and-grow using jQuery. I can't figure out how to get the height of the span/div though. I'm not going to set a specific value in CSS because it could change depending on the browser. Because of this, my JavaScript (style.height) always returns 0.

Any ideas?

like image 962
Freesnöw Avatar asked Nov 27 '22 18:11

Freesnöw


1 Answers

Here it is in plain js and no jQuery required:

document.getElementById("learning_menu").offsetHeight;
like image 195
Naftali Avatar answered Dec 15 '22 17:12

Naftali