Add remove class using jquery
We can use jquery to add and remove class to html elements using jquery addClass and removeClass methods. < style > .myClass { color : blue ; } .primary { color : black ; } </ style > < input type ="button" value ="Add Remove class" onclick =" AddRemoveClass() " /> < div id ="myDiv" class ="myClass"> This is a div </ div > < script type ="text/javascript"> function AddRemoveClass () { $( "#myDiv" ).removeClass( "myClass" ); $( "#myDiv" ).addClass( "primary" ); //One liner $( "#myDiv" ).removeClass( "myClass" ).addClass( "primary" ); } </ script...