toggleclass in javascript object of the element code example Example: jquery toggle class $( "#foo" ).toggleClass( 'className', addOrRemoveOptional );