This article summarizes several ways to get the specified element size and position using javascript.If you are using jquery, getting the element size is very simple.But we still need to know how to get it through native javascript,

First, get the inline style of the element

var obj=document.getelementbyid ("test");
alert (obj.height + "\ n" + obj.width);
// 200px 200px typeof=string just displays the value in the style attribute

Get the calculated style

var obj=document.getelementbyid ("test");
var style=null;
if (window.getcomputedstyle) {
 style=window.getcomputedstyle (obj, null);// non-ie
} else {
 style=obj.currentstyle;// ie
alert ("width =" + style.width + "\ nheight =" + style.height);

Note:If you do not set the width and height of the element,Then return the default width and height in non-IE browsers.Return auto string under ie

Third, get theand