0

Counting elements by class name?

So I was wondering if it's possible to count the number of elements with a certain class name using js.

30th Apr 2018, 8:19 PM
Daniel Cooper
Daniel Cooper - avatar
4 Respuestas
+ 5
document.getElementsByClassName() returns an array so the amount of elements is the length of the array, document.getElementsByClassName("class").length
30th Apr 2018, 11:47 PM
Toni Isotalo
Toni Isotalo - avatar
0
You should get the length of a call of GetElementsByClassName
30th Apr 2018, 9:07 PM
Bebida Roja
Bebida Roja - avatar
0
Well, I want to count the number of divs with the class name "entry" and display it on the webpage
30th Apr 2018, 11:02 PM
Daniel Cooper
Daniel Cooper - avatar
0
So dumb question how do I display it on the webpage
1st May 2018, 12:16 AM
Daniel Cooper
Daniel Cooper - avatar