mirror of
https://github.com/sergeyyarkov/add-persons.git
synced 2026-10-11 10:19:36 +03:00
added function showAlert
This commit is contained in:
parent
b8fa45aee8
commit
f93c5ef9df
@ -11,6 +11,13 @@ form button {
|
|||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
.alert {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.alert-wrap {
|
||||||
|
position: fixed;
|
||||||
|
right: 30px;
|
||||||
|
}
|
||||||
.modal {
|
.modal {
|
||||||
max-height: 460px;
|
max-height: 460px;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div class="alert-wrap"></div>
|
||||||
<div class="modal-mask">
|
<div class="modal-mask">
|
||||||
<div class="modal">
|
<div class="modal">
|
||||||
<div class="modal-head">
|
<div class="modal-head">
|
||||||
@ -26,9 +27,7 @@
|
|||||||
<th class="align-right">Job</th>
|
<th class="align-right">Job</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody></tbody>
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|||||||
@ -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) => {
|
$form.addEventListener('submit', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const _this = e.target,
|
const _this = e.target,
|
||||||
@ -29,6 +37,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
job = _this.job.value;
|
job = _this.job.value;
|
||||||
|
|
||||||
new Person(firstName, surName, age, job).addPerson();
|
new Person(firstName, surName, age, job).addPerson();
|
||||||
|
showAlert();
|
||||||
});
|
});
|
||||||
|
|
||||||
const showPersons = function () {
|
const showPersons = function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user