Is there a way to check there are any red color text in the website | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is there a way to check there are any red color text in the website

I want to check that the website has any coloured text. If found then it should return a Boolean value. Is that possible using javascript

28th Oct 2020, 5:39 AM
Çrèàtìvè Sàt
Çrèàtìvè Sàt - avatar
2 Answers
+ 2
Yes it's possible. My approach: Traverse the entire Dom tree and check textNode by textNode for color red. You can use getComputedStyle(node).color for that: https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle https://code.sololearn.com/WVUCihKrAcXZ/?ref=app
28th Oct 2020, 6:37 AM
Kevin ★
+ 2
Kevin ★ Thanks for answering my question.
28th Oct 2020, 10:48 AM
Çrèàtìvè Sàt
Çrèàtìvè Sàt - avatar