How to calculate <p> tag words? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 4

How to calculate <p> tag words?

I want to calculate p tag words, that how many words in p element through javascript any one guide me ??

6th Feb 2018, 8:54 PM
Nabeel Nasir
Nabeel Nasir - avatar
3 Réponses
+ 6
can also use length property with var pCount = document.querySelectorAll("P").length;
6th Feb 2018, 10:41 PM
Morpheus
Morpheus - avatar
+ 1
document.querySelector(#theptagid).innerHTML.split(" ").length
6th Feb 2018, 9:25 PM
Αητοιπe
Αητοιπe - avatar
+ 1
https://code.sololearn.com/WtPVY7XQwjNf/?ref=app tried it out thanks to Antoine Bergerault Have a nice day 👍
6th Feb 2018, 9:37 PM
Sebay
Sebay - avatar