Getting actual widh / height values ​​of an element through .getNamedItem attributes


I am trying to get the width / height values ​​of an element in a dom tree (HTML page) and I use the method below:

var event = e || window.event;
var target = event.target || event.srcElement;

I get identifier and class information using

var classinfo = target.attributes.getNamedItem("class").nodeValue;
var idinfo = target.attributes.getNamedItem("id").nodeValue;

but, as you can guess, any element has no identifiers and / or classes, so I can’t check the width = ".. px" node value or the getElementById method
As a result, is it possible to get the width and height of the node element using the getNamedItem / method or any other that you can advise.

NOTE: I need to get the actual width and height, not css or inline, because maybe the width is 60% in css, but it displays as 100px ...
Thanks in advance.
+4
source share
1 answer

element.offsetWidth, element.offsetHeight: total size of the containing window in pixels

element.clientHeight, element.clientWidth: content sizes

These properties are read-only and always return the current displayed values.

(You need to assign a style property in an element or in the stylesheet to set most elements at the height and width of the screen.)

+9
source

Source: https://habr.com/ru/post/1343264/


All Articles