Например: я добавил задачу Купить хлеб, и чтобы после перезагрузки эта задача осталась
<!DOCTYPE html>
<html lang="ru">
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css" >
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="text" id="input"><br>
<button id="button">Добавить задачу</button><br>
<div id="Monday"></div>
let todoList = [];
document.getElementById('button').onclick = function () {
let input = document.getElementById('input').value;
if (input !== '') {
let temp = {};
temp.todo = input;
temp.check = false;
let i = todoList.length;
todoList[i] = temp;
console.log (todoList);
out();
localStorage.setItem('todo', JSON.stringify(todoList))
function out() {
var out = '';
for (var i=0; i<todoList.length; i++) {
if (todoList[i].check)
out += '<span class="underlined"><input type="checkbox" checked> '+todoList[i].todo + '</span><br>';
else {
out+='<span><input type="checkbox"> '+todoList[i].todo + '</span><br>';
}
}
document.getElementById('Monday').innerHTML = out;
}
} else {
//alert('Error!');
let modal = document.getElementById('Madal');
let span = document.getElementById('span');
modal.style.display = "block";
span.onclick = function () {
modal.style.display = "none";
}
window.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
}
}