設定されている場合は a の値を取得し、その値で aをcookie
更新しようとします。それ以外の場合は、80 ~ 100 の間の乱数を生成し、それを として設定し、次に を更新します。div
cookie
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);
}