JavaScript Tutorial

Remove a class if element has it otherwise add the class

$("#elementid").toggleClass("class");