100-project-100-days-website/100_projects/49-test-notification-click/script.js
2023-04-11 01:27:50 +03:00
Ask

18 lines
452 B
JavaScript

{a13d4329c63b5270ab101628f4732be1661478e1 true 452 script.js 0xc0030c5e30}

const btn = document.getElementById("btn");
const container = document.getElementById("container");
btn.addEventListener("click", () => {
createNotification();
});
function createNotification() {
const notification = document.createElement("div");
notification.classList.add("test");
notification.innerText = "Warning..";
container.appendChild(notification);
setTimeout(() => {
notification.remove();
}, 3000);
}