How to add/remove class in multiple buttons to jquery

How to add/remove class in multiple buttons to jquery code- The objective is to use JQuery to add and remove classes from an HTML element. and add and remove one and more classes on click buttons to jquery very simple custom code given below-

How to remove/add multiple class in jquery for webpage

The following js code remove and add class for you need to add jquery cnd link (library file)on header part in your website and also copy below code and paste on site header part in after head tag for website.
Here ".intro" class we are doing added and removed to jquery, we have total 4 buttons classes as .button1, .button2, button3, .button4, It's custom jquery code working, we already used this one code.

how to add and remove multiple classes on buttons click in jquery

The following is the add/remove class click on multiple buttons to jquery in language:-

$(document).ready(function(){
  $(".button1").click(function(){  
    $(".button1").addClass("intro");
    $(".button2").removeClass("intro");
    $(".button3").removeClass("intro");
    $(".button4").removeClass("intro");
  });

  $(".button2").click(function(){
    $(".button2").addClass("intro");
    $(".button1").removeClass("intro");
    $(".button3").removeClass("intro");
    $(".button4").removeClass("intro");
  });
 
$(".button3").click(function(){
    $(".button3").addClass("intro");
    $(".button1").removeClass("intro");
    $(".button2").removeClass("intro");
    $(".button4").removeClass("intro");
  });
 
 $(".button4").click(function(){
    $(".button4").addClass("intro");
    $(".button1").removeClass("intro");
    $(".button2").removeClass("intro");
    $(".button3").removeClass("intro");
  });
   
});

Post a Comment

0 Comments