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

Where (odd) and (even) come from? And what is this?

On this section we find something that will be beginner like me confusing. Because on the querySelector we find the (odd) and (even). And on the DOM, I don't see this word anymore. Where is this come from? And for what?

You need to become familiar with CSS pseudo-classes. These classes are pre-defined. So, in the example given, the odd or even numbered list elements can be selected using :nth-child() pseudo-class with the odd or even keyword, respectively. See link below for more information.

https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes

1 Answer

Here is a fiddle of them in action in CSS to add on to what Timothy was saying:

http://jsfiddle.net/thirtydot/K3TuN/1323/

And one in javascript

http://jsbin.com/vaxuyivixo/1/edit?html,js,output