+ 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 Respostas
+ 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