试图获得a的价值 cookie
如果它的设置和更新a div
随着 cookie
值,否则生成80-100之间的随机数,设置为 cookie
,然后更新 div
。
我得到错误:
Object function (a,b){return new e.fn.init(a,b,h)} has no method 'cookie'
继承我的代码:
$(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);
}