mirror of
https://github.com/kevin-DL/complete-node-bootcamp.git
synced 2026-01-16 05:04:34 +00:00
15 lines
422 B
JavaScript
15 lines
422 B
JavaScript
/* 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);
|
|
};
|