- 1

Why is it only one <p> that gets highlighted?

Searching string highlight. Only content from the first <p> element is affected. How to overcome this?

20th Mar 2021, 10:56 AM
Adrian Kydland Skaftun
Adrian Kydland Skaftun - avatar
5 Antworten
+ 1
You need to use querySelectorAll() to get all the <p> elements which have the class you're looking for. You've used querySelector() which returns the first one if it finds one.
20th Mar 2021, 1:50 PM
CamelBeatsSnake
CamelBeatsSnake - avatar
0
Your code link?
20th Mar 2021, 1:17 PM
Khan ⭐
Khan ⭐ - avatar
0
Ohh shoot.. sorry. I copied, forgot to paste. Haha https://code.sololearn.com/WAsn5UEVfvdk/?ref=app
20th Mar 2021, 1:38 PM
Adrian Kydland Skaftun
Adrian Kydland Skaftun - avatar
0
Ahh! Thanks!!
20th Mar 2021, 1:51 PM
Adrian Kydland Skaftun
Adrian Kydland Skaftun - avatar
0
No problem. Glad I could help 🙂
20th Mar 2021, 1:53 PM
CamelBeatsSnake
CamelBeatsSnake - avatar