added function showAlert

This commit is contained in:
Sergey Yarkov 2019-10-20 00:01:40 +03:00
parent b8fa45aee8
commit f93c5ef9df
3 changed files with 18 additions and 3 deletions

View File

@ -11,6 +11,13 @@ form button {
margin-top: 20px;
margin-bottom: 0;
}
.alert {
padding: 20px;
}
.alert-wrap {
position: fixed;
right: 30px;
}
.modal {
max-height: 460px;
}

View File

@ -11,6 +11,7 @@
</head>
<body>
<div class="alert-wrap"></div>
<div class="modal-mask">
<div class="modal">
<div class="modal-head">
@ -26,9 +27,7 @@
<th class="align-right">Job</th>
</tr>
</thead>
<tbody>
</tbody>
<tbody></tbody>
</table>
</div>
<div class="modal-footer">

View File

@ -20,6 +20,14 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
const showAlert = function() {
const $alert = document.querySelector('.alert-wrap');
$alert.innerHTML += '<p class="alert alert-success">Person has been successfully added!</p>';
setTimeout(() => {
$alert.querySelector('p').remove();
}, 2000);
}
$form.addEventListener('submit', (e) => {
e.preventDefault();
const _this = e.target,
@ -29,6 +37,7 @@ document.addEventListener('DOMContentLoaded', () => {
job = _this.job.value;
new Person(firstName, surName, age, job).addPerson();
showAlert();
});
const showPersons = function () {