User Id :    Password :      New Member   Forgot Password  
 
How to add remove and change css class using JQuery
Description Here in this code snippet I will show how you can add, remove and change css class in JQuery dynamically.   No. of Views     80956
  Rating     0
Author Najmul Hoda   Posted On     25 Oct 2010
Tags ASP.NET,Java Script,JQuery and ASP.Net,HTML    

Sample Code   Download Code

In this article I will show you how you can add css class to the control using JQuery at dynamically.

 

To add css class to a control

$('myDiv').addClass('yourClass');

Here in the code above I am finding myDiv from the page and then calling addClass() method to add css class to the div.

 

To remove css class from a control

$('myDiv').removeClass('yourClass').

To remove css class from the div use removeClass().

 

To change css class of a control

$('myDiv').removeClass('yourClass').addClass('myClass');

To change a css class from the control we need to remove the existing class from the control and then add a new class name otherwise new class will be added to control along with existing class.

 

Enjoy Coding....................

 

About Author

About Author He is a team lead, having 8+ years of experience. He loves writing technical article for .Net developers. Najmul Hoda
No Photo
 
Country United States
Company BirlaSoft
Home Page http://www.magixchat.com

Rate this article

Rating options from poor, fair, good, very good to excelent.  
 

Comments

   
Write your comment here.
Comment
Verification Code