JavaScript jQuery Basics Working with jQuery Collections jQuery-Specific Selectors

Juneau Lim
Juneau Lim
11,213 Points

Inquiry about :odd

Isn't the elements I would be select, not necessarily to be siblings? If that is the case, can I add more than one conditions for :odd?

1 Answer

Steven Parker
Steven Parker
174,022 Points

Typically, ":odd" would be combined with other selectors, but it doesn't restrict the selection to siblings in itself.

Juneau Lim
Juneau Lim
11,213 Points

What I wondered was that if I could use more than one selector with :odd. i.e) (a, li):odd or (ul li):odd(Syntax doesn't make sense but I hope it would explain what I mean.) It's very interesting. Thanks for your answer!

Steven Parker
Steven Parker
174,022 Points

Some example valid syntax rules might be:

ul li:odd {    /* odd list items inside a ul */ }
.block a:odd { /* odd links in a container with class "block" */ }
div.col:odd {  /* odd divs that also have class "col" */ }
Juneau Lim
Juneau Lim
11,213 Points

Wow thanks for the example! It seems super useful!