Manipulate the style of elements Is easest.
jQuery can be Manipulating CSS
jQuery has many of methods for CSS manipulation. Let’s look at the following methods:
addClass() - Adds 1 or more than 1 classes in selected elements/contents
removeClass() - Removes 1 or more than 1 classes in selected elements/contents
toggleClass() - Toggles between adding/removing classes from the selected elements/contents
css() - Sets or returns style attribute
Example Stylesheet
Following stylesheet will be used for all the examples on this page:
jQuery addClass() Method
The following example shows how to add class attributes to different elements. And we can select multiple elements, when adding classes:
Example
You can also specify multiple classes within the addClass() method:
Example
jQuery removeClass() Method
The following example shows to remove a specific class attribute from different elements:
Example
jQuery toggleClass() Method
The following example will show how to use the jQuery toggleClass() method. This method toggles between adding/removing classes from the selected elements:
Example
Thank You
Required fields are marked *
Get all latest content delivered to your email free.