/
qewryt
/
Notes_app
Обзор
Документация
Войти
/
qewryt
/
Notes_app
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
notes-app/script.js
52 строки
1 KB
qewryt
create: index.html, index.txt, script.js, script.txt, style.css, style.txt
18 май 2026, 12:55
Верифицирован
18 май 2026, 12:55
70e12f9
Код
Авторство
О чём код?
const input = document.getElementById("noteInput"); const addBtn = document.getElementById("addBtn"); const list = document.getElementById("notesList"); loadNotes(); addBtn.addEventListener("click", addNote); function addNote() { const text = input.value.trim(); if (text === "") return; createNote(text); saveNote(text); input.value = ""; } function createNote(text) { const li = document.createElement("li"); li.textContent = text; const delBtn = document.createElement("button"); delBtn.textContent = "Удалить"; delBtn.className = "delete"; delBtn.onclick = () => { li.remove(); removeNote(text); }; li.appendChild(delBtn); list.appendChild(li); } function saveNote(note) { const notes = JSON.parse(localStorage.getItem("notes")) || []; notes.push(note); localStorage.setItem("notes", JSON.stringify(notes)); } function loadNotes() { const notes = JSON.parse(localStorage.getItem("notes")) || []; notes.forEach(createNote); } function removeNote(note) { let notes = JSON.parse(localStorage.getItem("notes")) || []; notes = notes.filter(n => n !== note); localStorage.setItem("notes", JSON.stringify(notes)); }