我正在构建一个简单的游戏,试图教我自己js/jQuery,并且无法让我的代码的这部分运行。 Firebug说在“endGame”函数后面有一个语法错误。如果我删除分号,Firebug会将错误移至下一行。我不知道我做错了什么。我仔细研究过,看看其他格式的语句是如何格式化的,并且无法发现问题。提前致谢。Javascript语法错误
var cs = current_score,
ts = total_score;
function score(){
if($('.col_1 div .picked').hasClass('x'||'w')) {
if($('.col_2 div .picked').hasClass('x'||'w')) {
cs += 25;
if($('.col_3 div .picked').hasClass('x'||'w')) {
cs += 75;
if($('.col_4 div .picked').hasClass('x'||'w')) {
cs += 225;
if($('.col_5 div .picked').hasClass('x'||'w')) {
cs += 675;
if($('.col_6 div .picked').hasClass('bonus_2')) {
cs += 2000;
}else if($('.col_6 div .picked').hasClass('bonus_5')) {
cs += 5000;
}else{}
}
}
}
}
}else if($('.col_1 div .picked').hasClass('y'||'w')) {
if($('.col_2 div .picked').hasClass('y'||'w')) {
cs += 25;
if($('.col_3 div .picked').hasClass('y'||'w')) {
cs += 75;
if($('.col_4 div .picked').hasClass('y'||'w')) {
cs += 225;
if($('.col_5 div .picked').hasClass('y'||'w')) {
cs += 675;
if($('.col_6 div .picked').hasClass('bonus_2')) {
cs += 2000;
}else if($('.col_6 div .picked').hasClass('bonus_5')) {
cs += 5000;
}else{}
}
}
}
}
}else {}
function endGame();
};
这是什么'function endGame(); };'??? –
在函数分数里面声明函数endgame? –
在发布语法错误之前,请通过http://jshint.com/或http://jslint.com运行您的代码。 – megawac