Javascript 在我的Raphael代码中发现错误
我是拉斐尔的新手,能够理解其中涉及的大部分基础知识,但我已经在这方面停留了一段时间,我相信在我的click函数中发现的if语句中有一个简单的语法错误Javascript 在我的Raphael代码中发现错误,javascript,jquery,if-statement,raphael,Javascript,Jquery,If Statement,Raphael,我是拉斐尔的新手,能够理解其中涉及的大部分基础知识,但我已经在这方面停留了一段时间,我相信在我的click函数中发现的if语句中有一个简单的语法错误 button.click(function() { //when the variable has been clicked light.animate({ //The variable light will animate if(light.attr("fill")
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
});
我不太喜欢拉斐尔,但你的JS语法错了。也许这会有帮助:
if (light.attr("fill") == "#ffffff" ){
light.animate({
fill: '#FFFF00'
}, 5000);
} else {
light.animate({
fill: '#ffffff'
}, 5000);
}
希望这有帮助。谢谢,帮了大忙