addClass() Method


The addClass() method is used to add one or more CSS classes to elements.

It helps apply styles dynamically without changing CSS files.

This method is commonly used for active menus, highlights, and UI states.

This adds the active class to the selected element.

This applies the class to multiple elements.

Classes can be added based on user interaction.

addClass() Method Notes:

  • Adds CSS class dynamically
  • Does not remove existing classes
  • Used for UI states
  • Common in navigation menus