Dynamically addClass CSS click using jQuery

Dynamically addClass CSS click using jQuery

Welcome to the In Pakainfo.com website! You will Step By Step learn web programming, easy and very fun. This website allmost provides you with a complete web programming tutorial presented in an easy-to-follow manner. Each web programming tutorial has all the practical examples with web programming script and screenshots available.

onclick add class remove class using jquery Example

<title>onclick add class remove class using jquery Example</title>


.myngclass {
    font-size: 180%;
    color: green;

<h1>jquery add remove class onclick</h1>
<div>onclick add class remove class</div>
<div>jquery onclick toggle class</div>
<button>jquery add css style</button>

Click Event After AddClass : jQuery addClass() Method


Add active class to Li on click jquery – Example

<li><a id="jquery-link" class="" href="#">jQuery</a></li>
<li><a id="php-link" href="#">PHP</a></li>
<li><a id="laravel-link" href="#">Laravel</a></li>
<li><a id="magento-link" href="#">Magento</a></li>
$('ul li a').click( function(){
    if ( $(this).hasClass('active') ) {
    } else {
        $('li a.active').removeClass('active');
a {
    transition:all 300ms;
.active {


Read Also:  jQuery toggleClass addClass removeClass Examples

Jquery Add active class to main menu : Script

  $('ul li a').click(function(){
    $('li a').removeClass("active");


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  remove class jquery
  2. Read Also:  Get Parent Elements With CSS and jQuery
  3. Read Also:  How to Create, Access and Destroy Sessions in Laravel
  4. Read Also:  javascript get element by class
  5. Read Also:  remove class jquery
  6. Read Also:  Angular 6 Module File Tutorial with Examples
  7. Read Also:  PHP Laravel 6 Global Variable Example
  8. Read Also:  Angular 6 Image Upload with Validation Example
  9. Read Also:  jQuery Remove Class From HTML Elements Example
  10. Read Also:  Top 10 Advanced Laravel Interview Questions Answers