Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 :)