trying to get the value of a cookie if its set and update a div with the cookie value, otherwise generate a random number between 80-100, set that as the cookie, and then update the div.
im getting the error:
Object function (a,b){return new e.fn.init(a,b,h)} has no method 'cookie'
heres my code:
$(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);
}
There is no
cookiemethod in standard jQuery.Perhaps the code requires on jquery-cookie or another plugin?
Happy coding.