[jQuery] Getting jQuery to recognise the addClass function
I'm trying to create a page whereby the user can click on an element
(in this case, a list item (<li>)) to cycle through differnet css
classes.
I'm using the removeClass/addClass function to swap the class (which
is successful), however I want to then use new class for a different
removeClass/addClass function (which is unsuccessful).
Below is the code. It should seem fairly obvious what I want to
achieve.
$(".class1").click(function() {
$(this).removeClass("class1");
$(this).addClass("class2");
});
$(".class2").click(function() {
$(this).removeClass("class2");
$(this).addClass("class3");
});
$(".class3").click(function() {
$(this).removeClass("class3");
$(this).addClass("class1");
});
It seems like a fairly simple problem, but then I only know server
side scripting