Jquery Uncaught SyntaxError:意外的令牌:

时间:2016-07-22 02:48:06

标签: jquery

我在Google Chrome中遇到Uncaught SyntaxError: Unexpected token :错误。我知道这意味着,但我不明白如何解决这个错误。

$(function(){
    $('.hunbun').readmore(function(){
        speed: 1000,
        collapsedHeight: 200, // < here get the that error
        moreLink: '<a href="#">read more</a>',
        lessLink: '<a href="#">close</a>'
    });
});  

1 个答案:

答案 0 :(得分:0)

是的,你有语法错误:.readmore调用需要对象参数传递函数引用,在函数体中你写下你应该写的对象:

$(function(){
    $('.hunbun').readmore({
        speed: 1000,
        collapsedHeight: 200, // < here get the that error
        moreLink: '<a href="#">read more</a>',
        lessLink: '<a href="#">close</a>'
    });
});     

从第二行删除function()