1
Guys I’m trying to save my timer
in the local storage
but it is not saving it when I enter my console it does not appear follow my code HTML and JS
html
<div id="timer">
<span id="minutes"></span>:<span id="seconds"></span>
</div>
JS
window.onload = function() {
var access = localStorage.getItem('firstAccess');
if(access == '') {
var d = new Date();
console.log(d);
var time = localStorage.setItem('firstAccess', JSON.stringify(d));
setTimer(time);
}
else {
setTimer(access);
}
function setTimer(time) {
var timespan = countdown(time).toString();
$('#minutes').html(timespan.minutes);
$('#seconds').html(timespan.seconds);
}
}
Here is where the set name Item that is firstAccess should appear
Some mistake in the
console
?– Rafael Augusto
@Rafaelaugusto no more I will put the console print in the question but I do not know why not saved should have some problem in the code that I did not understand
– Felipe Henrique
I answered your question with error
– Rafael Augusto