How to add or remove CSS class using jQuery?

Let us have an html tag which contains few CSS classes. We can remove or add CSS classes dynamically through jQuery.

For Example,

Following is the html code:

font-style: italic;
color: #ff0000;
font-style: bold;
color: #ff00ff;
<input type="text" id="id_1" value="rosary" class="red"/>

To remove CSS class red dynamically through jQuery, use removeClass() jQuery inbuilt function.

<script type="text/javascript">

To add CSS class blue dynamically through jQuery, use addClass() jQuery inbuilt function.

<script type="text/javascript">

Share This Post

Related Articles

Leave a Reply

© 2018 Techy Diary. All rights reserved.
Powered by Charvi Groups