Answers for "add active class to button onclick jquery"

1

add active class to button onclick jquery

/*
  CSS:
  .active{
    background-color: red;
    color: #fff;
    font-weight: bold;
  }
*/
/* Before Execution*/
<button class="my-btn">Login</button>
$(".my-btn").click(function() {
  $(this).addClass("active");
})
______________________________________________
/* After Execution*/
<button class="my-btn active">Login</button>
Posted by: Guest on June-17-2021

Code answers related to "add active class to button onclick jquery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language