JavaScript JavaScript and the DOM Getting a Handle on the DOM Using CSS Queries to Select Page Elements

SyntaxError: 'li;nth-child(even)' is not a valid selector

SyntaxError: 'li;nth-child(even)' is not a valid selector

This is my error message. I am guessing my brain needs a break and i am overlooking something. Can someone correct me, everything looks correct to me but obviously i did something wrong.

const evens = document.querySelectorAll('li;nth-child(even)');

for ( let i = 0; i < evens.length; i += 1 ) { evens[i].style.backgroundColor = 'lightgray'; }

2 Answers

Nevermind, I see where I was wrong. After selecting the list element I put a semicolon instead of a colon. Lol knew i was doing something dumb.

Vasanth Baskaran
Vasanth Baskaran
4,333 Points

Thanks for pointing out the error. Happy Coding :)