I’m trying to create simple function that will work two ways. Basically, when I click on .slideme once it will add a class, and when I click second time it will remove that class.
I have this:
$(".slideme").click(function() {
$('#login').addClass("green");
},function(){
$('#login').removeClass("green");
});
Unfortunately it works only half way; when I click the second time nothing happens.
How can I solve this please?
Just use toggleClass:
Working example: http://jsfiddle.net/AndyE/ZQfeW/