se si cerca di ottenere il valore di cookie
se è impostato e aggiorna un div
con cookie
valore, altrimenti generare un numero casuale compreso tra 80 e 100, impostarlo come cookie
e quindi aggiornare div
.Funzione oggetto (a, b) {return new e.fn.init (a, b, h)} non ha alcun metodo 'cookie'
im ottenere l'errore:
Object function (a,b){return new e.fn.init(a,b,h)} has no method 'cookie'
heres il mio codice:
$(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);
}
Sembra che questo era il plugin che stavate cercando: https://github.com/carhartl/jquery-cookie Ho pensato di aggiungo dal momento che questo mi ha aiutato pure. –