Показать сообщение отдельно
  #38 (permalink)  
Старый 07.04.2020, 00:53
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,070

Pavel_16,
страница рекордов
<!DOCTYPE html>
<html>
<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <style type="text/css">
  table{
    border: 1px solid #000000;
    border-collapse: collapse;
  }
  td{
    border: 1px solid #000000;
  }

  </style>

  <script>
document.addEventListener( "DOMContentLoaded" , function() {
if (localStorage.getItem("users") === null) {
    localStorage.setItem("users", JSON.stringify([]));
}

let users = JSON.parse(localStorage.getItem("users"));
let userName  = localStorage.getItem("userName");
let time = localStorage.getItem("time");
if(time) {
users.push({userName, time});
localStorage.setItem("users", JSON.stringify(users));
localStorage.removeItem('time');
}
let html = ''
for (const {userName, time} of users) html +=
    `<tr>
        <td>${userName}</td>
        <td>${time}</td>
    </tr>`;
document.querySelector('table tbody').innerHTML = html;

  });

  </script>
</head>
<body>
<table>
<thead><tr>
        <td>имя</td>
        <td>время</td>
    </tr>
</thead>
<tbody></tbody>
</table>
</body>
</html>
Ответить с цитированием