Here we are going to explain what is addClass() function or how to use addClass() function or why use addClass() function or how to add class to the selected elements  in jQuery with example.


The jQuery addClass() method is used to add one or more class name to the selected html element. This method is used only to add one or more class names to the class attributes. It is not remove the existing class name to the class attributes.

If you want to add more than one class separate the class names with spaces.



Let’s see, Example of jQuery addClass() method:

 <!DOCTYPE html>
<html xmlns="">
    <title>Example of jQuery addClass method</title>
    <script type="text/javascript" src=""></script>
        .Content {
            background-color: yellow;
            font-size: 25px;
    <script type="text/javascript">
        $(document).ready(function () {
            $("button").click(function () {
    <p>SQL Tutorials Point</p>
    <button>Add Class</button>

 Let's check live example

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like