add active class to button onclick jquery

Solutions on MaxInterview for add active class to button onclick jquery by the best coders in the world

showing results for - "add active class to button onclick jquery"
Anna
23 May 2019
1/*
2  CSS:
3  .active{
4    background-color: red;
5    color: #fff;
6    font-weight: bold;
7  }
8*/
9/* Before Execution*/
10<button class="my-btn">Login</button>
11$(".my-btn").click(function() {
12  $(this).addClass("active");
13})
14______________________________________________
15/* After Execution*/
16<button class="my-btn active">Login</button>
17