0

Scroll box

I want scroll box for product description when text length more than 100 word.(condition for applying overflow property)

11th Feb 2022, 5:51 AM
Reza Nargesi
Reza Nargesi - avatar
1 Resposta
0
In the below code the function checks the word count and if the word count is more or equal to 100 it applies the property of scroll to the p element. let p = document.querySelectorAll('p'); function getWordCounts(nodeList) { var wordCount = 0; for ( var i = 0; i < nodeList.length; i++ ) { wordCount += nodeList[i].textContent.trim().split(' ').length; if (wordCount >= 100){ p[i].style.overflow = "scroll"; } } } getWordCounts(p);
11th Feb 2022, 9:06 AM
Shaurya Kushwaha