Jquery CSS Classes

Jquery addClass()

This method is used to add class in the element.

$(document).ready(function(){
 $('button').click(function(){
  $('.test').addClass('blue');
 });
});



Jquery removeClass()

This method is used to remove class in the element.

$(document).ready(function(){
 $('button').click(function(){
  $('.test').removeClass('blue');
 });
}); 


Jquery toggleClass()

This method toggles between adding and removing classes from selected elements.

$(document).ready(function(){
 $('button').click(function(){
  $('.test').toggleClass('blue');
 });
}); 

Share this

Related Posts