Try something like.. $("#btnTraffic").click(function(){ if ($("#trafficLight").css("background-color") == 'green') { $("#trafficLight").css("background-color", "yellow"); } else if ($("#trafficLight").css("background-color") == 'yellow') { $("#trafficLight").css("background-color", "red"); } else { $("#trafficLight").css("background-color", "green"); } });
That should do it for you. - T.J. On Dec 15, 9:55 am, Glen_H <glen.f.he...@gmail.com> wrote: > here is my problem: > > $("#btnTraffic").click(function(){ > $("#trafficLight").css("background-color","yellow"); > > }); > > btnTraffic is my button, when I click it, it changes from red to > yellow because of the css. > > I want to click it multiple times and have it rotate between red, > yellow and green. > > so it starts red, I click it, it turns yellow, then I click it and it > turns green, then click again back to red, so on and so forth. anyone > have any idea how to make that happen? I can change it once no > problem, but I need some type of loop command or something like that. > > Thanks in advance ! > > Glen