Hei guys, i recently started to develop an auto recognizer of all div tags from DOM.
I would like to get their properties, like offsetWidth, offsetLeft, ... as the console return when i try to show the variable.
my code looks like:
var elements = [];
elements.push(document.querySelectorAll('body > div'));
console.log(elements);
The console return:
[NodeList[3]]
0: NodeList[3]
0: div
1: div
2: div
length: 3
__proto__: NodeList
length: 1
__proto__: Array[0]
The HTML:
<div style="left:40px;top:10px;position:absolute">
<img src="assets/images/text1.png" />
</div>
<div style="left:200px;top:88px;position:absolute">
<img src="assets/images/text2.png" />
</div>
<div style="left:85px;top:166px;position:absolute">
<img src="assets/images/text3.png" />
</div>
My question is:
How i can access the array with my divs so i can get its length, its whole properties (like offsetLeft
) if the expanded div in console shows properties like x,y,naturalHeight and many others...
EDIT
Sorry, i forgot to mention, the code should be PURE JS! Sorry for the wrong jQuery tag added...