Files
web-authenticator/src/toast.ts
2023-08-27 20:26:25 -04:00

14 lines
497 B
TypeScript

export function toast(element: HTMLDivElement, message: string) {
// Target our predefined DIV that will hold toast messages.
const toastDiv = element.getElementsByClassName('toast')
// If we currently have a toast displayed, let's remove it from the DOM.
if (toastDiv && toastDiv.length != 0) {
for (const el of toastDiv){
el.remove()
}
}
// Finally add our toast message.
element.innerHTML += `<div class='toast'>${message}</div>`
}