I want to automatically save the value of var memo in localStorage so after restarting the browser the value of the input #memo doesn't change. Can anyone show me how to do it?
<script>
$(document).ready(function () {
var memo = document.getElementById('memo');
memo.val = memo.value;
if (typeof(Storage) !== "undefined") {
window.localStorage.setItem('memo', memo.value);
window.localStorage.getItem('memo');
} else{
console.log('Web Storage is not supported');
}
var ajax_call = function () {
$.ajax({
type: "GET",
url: "test.php",
dataType: "html",
success: function (response) {
color = response;
console.log(color);
if (color == white) {
memo.val++;
memo.value = memo.val;
} else {
console.log("Color is not white");
}
}
});
}
var interval = 30000;
setInterval(ajax_call, interval);
});
</script>
<input type="text" id="memo">