JQuery has a version of toggleClass to make this a one liner: http://api.jquery.com/toggleClass/#toggleClass-switch