对象函数(a,b){return new e.fn.init(a,b,h)}没有方法'cookie'

sca*_*and 11 cookies jquery

试图获取a的值,cookie如果它的值设置并divcookie值更新a ,否则生成80-100之间的随机数,设置为cookie,然后更新div.

我得到错误:

Object function (a,b){return new e.fn.init(a,b,h)} has no method 'cookie' 
Run Code Online (Sandbox Code Playgroud)

继承我的代码:

$(document).ready(function(){

    var thecounter = '';

    if ($.cookie('thecounter') == null)
    {
        thecounter = $.randomBetween(80, 100);
        $.cookie('thecounter', thecounter, { path: '/' });
    }
    else
    {
        thecounter = $.cookie('thecounter');
    }

    $('dd-counter-num').html(thecounter);

    setTimeout(newtime, 5000);

});

function newtime () {

    var newtime = $.cookie('thecounter') + $.randomBetween(1, 2);
    $.cookie('thecounter', newtime, { path: '/' }); 
    $('dd-counter-num').html(newtime);
    setTimeout(newtime, 5000);

}
Run Code Online (Sandbox Code Playgroud)

小智 14

标准jQuery中没有cookie方法.

也许代码需要jquery-cookie或其他插件?

快乐的编码.