/
Coderdev
/
web-static-labs
Обзор
Документация
Войти
/
Coderdev
/
web-static-labs
Код
Запросы
0
Задачи
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
html/lab6/task7/profiles_list.html
49 строк
2 KB
Coderdev
1
12 май 2026, 12:37
12 май 2026, 12:37
d8ecd0f
Код
Авторство
О чём код?
<!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8"> <title>Сохраненные профили</title> </head> <body> <h2>Список сохраненных профилей</h2> <div id="profiles-container"></div> <br> <a href="index.html">Вернуться назад</a> <script> const container = document.getElementById('profiles-container'); function renderProfiles() { const profiles = JSON.parse(localStorage.getItem('saved_profiles')) || []; container.innerHTML = ''; if (profiles.length === 0) { container.innerHTML = '<p>Список пуст</p>'; return; } profiles.forEach((user, index) => { const div = document.createElement('div'); div.style.border = "1px solid #ccc"; div.style.margin = "10px"; div.style.padding = "10px"; div.innerHTML = ` <img src="${user.photo}"> <p>${user.name} (${user.email})</p> <button onclick="deleteProfile(${index})">Удалить профиль</button> `; container.appendChild(div); }); } window.deleteProfile = (index) => { const profiles = JSON.parse(localStorage.getItem('saved_profiles')) || []; profiles.splice(index, 1); localStorage.setItem('saved_profiles', JSON.stringify(profiles)); renderProfiles(); }; renderProfiles(); </script> </body> </html>