Home javascript find out the height of the element via JavaScript, if it is...

find out the height of the element via JavaScript, if it is spelled out in the style of




How can I get a height element via JavaScript, if it is registered in the style of style.css ?


. Menu_BotTom {
  HEIGHT: 100px;


& lt; div id = "menu_bottom" class = "menu_bottom" & gt;
  & lt; script type = "text / javascript" & gt;
    Alert (document.getelementByid ("menu_bottom"). style.Height);
  & lt; / script & gt;

It is necessary that the message alert (...) showed the height of this item (just a number, without a unit of measure).

Answer 1, Authority 100%

The easiest way to use jQuery :

$ ('# menu_bottom'). Height ();

without jQuery can be used:

var h = document.getelementbyid ('menu_bottom'). ClientHeight;
VAR H = Document.getelementByid ('menu_bottom'). offsetHeight;
VAR H = Document.getelementByid ('menu_bottom'). ScrollHeight;

clientheight Content height with padding fields, but without a scroll bar.

offsetheight “external” block height, including frames.

scrollheight Complete internal height, including scrolled area.

Answer 2, Authority 25%

var test = document.getelementbyid ("menu_bottom");
var height = window.getcomputedStyle (Test, NULL) .Height;
Alert (Height);

for ie:

var body = document.getelementsbytagname ("body");
var bg = body.currentStyle.Height;


Answer 3, Authority 25%

For JS Snacking styles, so use GetComputedStyle

Answer 4

alert (document.getelementbyid ('menu_bottom'). ClientHeight);

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions