Answers for "jquery add active class"

1

jquery add active class

/*
  CSS:
  .active{
    color: red;
    font-weight: bold;
  }
*/
/* Before Execution*/
<a href="google.com" class="my-link">Google</a>
$(".my-link").click(function() {
  $(this).addClass("active");
})
______________________________________________
/* After Execution*/
<a href="google.com" class="my-link active">Google</a>
Posted by: Guest on June-17-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language