What are classQueries?

classQueries are basically class-attributes that trigger DOM changes on the page.

Structure

classQueries always consist of 4 parts. Each part is separated with an underscore (_).

These are the different parts:

1st part - "cq"

An indicator that the class is a classQuery. Always "cq"!

2nd part - EVENT

The event that triggers the classQuery. Example: 'click' Look herearrow-up-right for more info!

3rd part - ACTION

The action that the classQuery fulfills. Example: 'hide' The action-part is special: It's the most important part of the classQuery, and therefore it needs arguments! Each argument is separated with a hyphen (-). Example: 'addClass-hidden' <- Adds the class ".hidden" For more info about arguments and actions, look herearrow-up-right!

4th part - SELECTOR

The element where the action happens. Example: 'id-veryImportantLink' Look herearrow-up-right for more info!

Examples

  • Hide an element on button click:

  • Add a class to an element when the finished loading:

  • Smoothly scroll to different parts of the website:

  • More examples coming soon!

Last updated

Was this helpful?