0

I have two level tag entry

<div>...<div>...</div>..</div>

How can I get to know how many of such tag entries was used on the page using document.querySelector()? Should I right something like this?

document.querySelectorAll('div > div')
SalmanRote
  • 23
  • 5
  • Does this answer your question? [the quantity of elements which include levels](https://stackoverflow.com/questions/66967983/the-quantity-of-elements-which-include-levels) – rook218 Apr 06 '21 at 18:36
  • Its a different question, look more attentively please – SalmanRote Apr 06 '21 at 18:37
  • I would recommend learning more about the selector api since you have multiple very closely related questions: https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors – rook218 Apr 06 '21 at 18:49

2 Answers2

1

To find out how many, you just need to do

document.querySelectorAll("div > div").length;

Thats it

Alpha
  • 36
  • 1
  • 5
0

You asked this same question earlier today and got complete answers but didn't mark them.

the quantity of elements which include levels

rook218
  • 644
  • 7
  • 20