jquery if hasclass addclass else removeclass code example Example: addclass removeclass jquery $( "p" ).addClass( "myClass yourClass" );