mirror of
https://github.com/kevin-DL/complete-node-bootcamp.git
synced 2026-01-21 07:05:04 +00:00
Initial commit 🚀
This commit is contained in:
14
4-natours/after-section-13/public/js/alerts.js
Normal file
14
4-natours/after-section-13/public/js/alerts.js
Normal file
@@ -0,0 +1,14 @@
|
||||
/* eslint-disable */
|
||||
|
||||
export const hideAlert = () => {
|
||||
const el = document.querySelector('.alert');
|
||||
if (el) el.parentElement.removeChild(el);
|
||||
};
|
||||
|
||||
// type is 'success' or 'error'
|
||||
export const showAlert = (type, msg) => {
|
||||
hideAlert();
|
||||
const markup = `<div class="alert alert--${type}">${msg}</div>`;
|
||||
document.querySelector('body').insertAdjacentHTML('afterbegin', markup);
|
||||
window.setTimeout(hideAlert, 5000);
|
||||
};
|
||||
Reference in New Issue
Block a user