javascript countdown timer with cookies
- by jwesonga
I have a countdown timer that will show a target amount to be fundraised like USD1000000 and slowly count backwards to zero over a period of days. I got this snippet:
$(function()
{
var cnt = 75000000;
var count = setInterval(function()
{
if (cnt > 0)
{
$('#target').html("<span>KSHS</span><strong>" + cnt + " Target </strong>");
cnt--;
}
else
{
clearInterval(count);
$('#target').html("<strong> Target Achieved! </strong>");
}
}, 4000);
});
The only problem is that everytime you refresh the page the counter starts again which essentially means it will never end.
I'd like it that a when a user revisits/refreshes the page the counter persists and continues. I've read that javascript cookies can be used for this, just don't know how to implement them, any help?