The console.log of element.children shows a length of 0, but has three entries when expanded later

In my javascript, I have two elements.

I registered two items and it shows ...

Element 1.

enter image description here

Element 2.

enter image description here

There is a problem.

When I console.log elements .children, they obviously return some HtmlCollections

You will understand what this means in a minute: But it is strange that one HtmlCollection is empty (and has a length of 0), but has 3 elements (and has a length of 3).

If you read console.logbelow for children, you will understand what I'm talking about ...

Element 1 children and length:

enter image description here

2 children item and length: (spoiled one)

enter image description here

Does anyone know what is going on here?

How to fix this, I need a loop through the HtmlCollection, but that will not allow me, because the length is 0 ...?

Thanks in advance! All help was appreciated.

+4
1

, ( ); live reference. , , . .

, , , , . , . , script, script </body>.

(i) ; , :

Tooltip saying

: " , ".

+14

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


All Articles