I'm trying to write a toast notification for users on a small website. I currently have a function that initializes this code and I was expecting this function to generate a container in which my toast notification will be placed.
Here is my initialization function.
let toastContainer;
(function initToast () {
document.body.insertAdjacentHTML('afterbegin', '<div class="toast-container"></div>');
toastContainer = document.querySelector('.toast-container');
})()
I was expecting this to create a <div class='toast-container' in the DOM, but this is not appearing in the DOM. I was thinking it may be an issue with the quotes I'm using?