In the client side javascript for the onclick event, take a look at the dojo.replaceClass method. This will replace a classname with another classname. It works really well. However, if you're not on 8.5.3 try dojo.addClass and dojo.removeClass. Once you're done with the class manipulation return true for the client side javascript and then the ssjs will run.
HTH
Keith