How to add and remove css classes to an element using jquery?



How to add and remove css classes to an element using jquery?..

Answer / Rajnish Mohan Saxena

To add a class, use the `addClass()` method: `$('.selector').addClass('myClass');`. To remove a class, use the `removeClass()` method: `$('.selector').removeClass('myClass');`

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More jQuery Interview Questions

How to read cookies in jquery?

1 Answers  


How to get the style property of an element using ?

1 Answers  


What is the use of jQuery filter?

1 Answers  


Explain the difference between .js and .min.js?

1 Answers  


Is it too early to discuss jquery ui 1.8?

1 Answers  


How to search for descendant elements that match the specified selectors using ?

1 Answers  


What are the advantage of using minimized version of jquery?

1 Answers  


How can events be prevented from stopping to work after an ajax request?

1 Answers  


Difference Between Prop and Attr in jQuery?

1 Answers  


Explain the script build up by jquery?

1 Answers  


What is the difference between $('div') and $('<div/>') in jQuery?

1 Answers  


How do you implement animation functionality?

1 Answers  


Categories