我是拉斐尔的新手,可以理解所涉及的大部分基础知识,但现在已经坚持了一段时间,我相信我在点击功能中找到的if语句中有一个简单的语法错误
button.click(function() {
//when the variable has been clicked
light.animate({
//The variable light will animate
if(light.attr("fill") == "#ffffff"){
//if the light has a fill of white
fill: '#FFFF00'
//then it will change to yellow
}
else(){
//else if the light has any other colour
fill: '#ffffff'
//then it will fill the light with white
}
//fill: '#FFFF00'
}, 5000);
//it will take five seconds for the new colour to be fully lit up
});
答案 0 :(得分:0)
我没有那么多拉斐尔,但你的JS语法错了。也许这会有所帮助:
if (light.attr("fill") == "#ffffff" ){
light.animate({
fill: '#FFFF00'
}, 5000);
} else {
light.animate({
fill: '#ffffff'
}, 5000);
}
希望这有帮助。