Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) 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 :)