未捕获的语法错误:意外的标记{

Uncaught SyntaxError: Unexpected token {

本文关键字:意外 错误 语法      更新时间:2023-09-26

当前使用的jQuery

$("#like_button").live("click", function(){
    var status = $(this).data("status");
    var id = $(this).data("id");
    var count = $(this).html();
        if(status === 1){
            like(id);
            $(this).removeClass("likes");
            $(this).addClass("liked");
            count++;
            $(this).html(count);
        }elseif(status === 2){
            like(id);
            $(this).removeClass("liked");
            $(this).addClass("likes");
            count--;
            $(this).html(count);
        }   else   {
            // do nothing
        }
        return false;
});

错误

Uncaught SyntaxError: Unexpected token { (Line 529)

,下面哪条线

}elseif(status === 2){

如果你需要更多的信息来帮助我,请务必询问。

JavaScript使用else if,而不是elseif

阅读本教程以了解有关if-else语句的更多信息http://www.w3schools.com/js/js_if_else.asp

此语句

}elseif(status === 2){

必须是

 }else if(status === 2){

如果

,则else之间缺少空格