我不知道问题出在哪里,但切换不起作用:
$("#header").toggle(
function(){$("#header").css({"background-color": "pink"});},
function(){$("#header").css({"background-color": "blue"});},
function(){$("#header").css({"background-color": "green"});
});
答案 0 :(得分:3)
这是你想要实现的目标吗?
看看这个小提琴:fiddle
在javascript中使用它:
var colors = ["pink", "blue", "green"];
var index = 0;
$("#header").click(function() {
index++;
if(index > colors.length - 1)
index = 0;
$("#header").css({
"background-color": colors[index]
});
});