What is the addclass() method in jQuery?

The addClass() method adds one or more class names to selected HTML elements. This method helps with changing the CSS properties of these HTML elements at a later stage. However, it does not remove existing class attributes; instead, it adds only one or more class names to the existing class attribute.

Syntax

svg viewer

Code

The following example​ demonstrates the use of the addclass() function. Upon clicking the button, the newclass class gets assigned to it, thus, changing the button’s CSS properties.

New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved