Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在我的Raphael代码中发现错误_Javascript_Jquery_If Statement_Raphael - Fatal编程技术网

Javascript 在我的Raphael代码中发现错误

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")

我是拉斐尔的新手,能够理解其中涉及的大部分基础知识,但我已经在这方面停留了一段时间,我相信在我的click函数中发现的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
    });

我不太喜欢拉斐尔,但你的JS语法错了。也许这会有帮助:

if (light.attr("fill") == "#ffffff" ){
    light.animate({
        fill: '#FFFF00'
    }, 5000);
} else {
    light.animate({
        fill: '#ffffff'
    }, 5000);
}

希望这有帮助。

谢谢,帮了大忙