gpt4 book ai didi

javascript - 我的 Raphael 代码中发现错误

转载 作者:行者123 更新时间:2023-11-28 08:23:26 24 4
gpt4 key购买 nike

我是 Raphael 的新手,可以理解所涉及的大部分基础知识,但已经坚持了一段时间了,我相信我的点击函数中的 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
});

最佳答案

我不太喜欢 Raphael,但你的 JS 语法是错误的。也许这会有所帮助:

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

希望这有帮助。

关于javascript - 我的 Raphael 代码中发现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22709049/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com