What you're actually doing with .attr
is just getting the value of a supposed static-color
attribute which doesn't exist.
The trick is using .addClass
.removeClass
or in this case .toggleClass
.
Another tip I have for you is to use event delegation with the .on
jQuery method. This will allow for more flexible event handling. You are actually attaching the listener to a parent element which will listen for events coming from another element matching the specified selector, like this:
$("#login-register").on('click', '.static-color', function() {
$('.active-color, .static-color').toggleClass("active-color static-color");
$("#login, #register").toggle();
});
Also, I see you have a bit of duplication, try to make your code more reusable. Don't Repeat Yourself!
I updated your fiddle: http://jsfiddle.net/h3Y6G/1/