+ 2

Why querySelectorAll property is not working šŸ™

Really Javascript is very confusing language... sometimes I can not understand why it's not working even though I write Correct properties, tags, classNames šŸ¤”? https://code.sololearn.com/WPpRrYWR96y7/?ref=app

15th Sep 2022, 6:46 AM
Pooja Sahoo
Pooja Sahoo - avatar
4 Answers
+ 1
Try this : const lists = document.querySelectorAll(".hello") const listItem = [...lists].map(el=>el.style= "background-color:red;");
15th Sep 2022, 11:06 AM
Prashanth Kumar
Prashanth Kumar - avatar
+ 4
You wrote javascript in style tag šŸ˜… it should be in script tag and querySelectorAll returns array so you need to iterate through it
15th Sep 2022, 6:56 AM
Prashanth Kumar
Prashanth Kumar - avatar
+ 3
Thanks a lot to clear my doubts and solve my problems šŸ˜‡
15th Sep 2022, 11:50 AM
Pooja Sahoo
Pooja Sahoo - avatar
+ 2
Oh sorry.... šŸ¤­šŸ˜›
15th Sep 2022, 10:00 AM
Pooja Sahoo
Pooja Sahoo - avatar