In this example, we will show add and remove class in jquery on click. I explain step by step add and remove the class name in jquery. In this example, you learn how to add and remove a class in jquery.

We will explain an example of add remove class jquery using a single button. single button to you can add class and remove class. I will show add and remove class using jquery.


<!DOCTYPE html>
<html lang="en">
  <title>Add and Remove Class in jQuery on Click</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="">
  <script src=""></script>
  <script src=""></script>
  <link href="" rel="stylesheet">


<div class="container">
    <table class="table table-bordered">
        <?php $id = 1; ?>
            <tr class="tr_<?= $id ?>">
                <td><input type="text" id="firstname" value="John" class="form-control" disabled></td>
                <td><input type="text" id="lastname" value="Doe" class="form-control" disabled></td>
                <td><input type="email" id="email" value="" class="form-control" disabled></td>
                    <button class="btn btn-primary btn_edit" data-id="<?= $id ?>"><i class="fas fa-edit"></i></button>

            alert("Edit Action");
            var id = $(this).attr("data-id");
            return false;
            alert("Save Action");
            var id = $(this).attr("data-id");
            return false;


I hope you understand of add and remove class in jquery using on button click and it can help you…