试图获取a的值,cookie如果它的值设置并div用cookie值更新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)
| 归档时间: |
|
| 查看次数: |
20193 次 |
| 最近记录: |