I
I
Ilya Famin2020-05-02 08:32:49
JavaScript
Ilya Famin, 2020-05-02 08:32:49

Script to track the number of certain tags on a page?

Suppose there is a tag aside, you need to track their number and display this number on the page

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Pastukhov, 2020-05-02
@Fama18122000

Well, for example, in the forehead you can:

const resultDiv = document.createElement('div')
document.body.appendChild(resultDiv);

setInterval(() => {
  const count = document.querySelectorAll('div').length;
    resultDiv.innerText = count;
  
}, 500)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question