0PricingLogin
jQuery Academy · Lesson

Pseudo-Class and Custom Selectors

Understand built-in pseudo-classes like :has(), :not(), and :nth-child(), then learn to create your own custom selectors for reusable element filtering.

Unlock Power with Pseudo-Classes

Welcome to Advanced Selectors! Today, we'll explore pseudo-classes, special keywords added to selectors to define a special state of the selected element.

  • They let you target elements that aren't easily selected by standard HTML attributes or names.
  • Think of them as dynamic filters for your selections.

They start with a colon (:), like :hover or :first-child.

Target by Position: :nth-child()

The :nth-child() pseudo-class selects elements based on their position among a group of siblings. It's incredibly useful for styling lists or table rows.

  • :nth-child(n): Selects the nth child.
  • :nth-child(odd): Selects odd-numbered children.
  • :nth-child(even): Selects even-numbered children.

The counting starts from 1 for the first child.

All lessons in this course

  1. Advanced Attribute Selectors
  2. Pseudo-Class and Custom Selectors
  3. Efficient DOM Traversal Techniques
← Back to jQuery Academy