CodeNewbie Community 🌱

Join the CodeNewbie Community 🌱

CodeNewbie Community 🌱 is a community of 33,255 amazing newbies

Forgot password?
By signing in, you are agreeing to our privacy policy, terms of use and code of conduct.

Since this is an invite-only community, you cannot join without an invitation. If you would like to request an invitation, please contact the community admin at noreply@forem.com

const modalMarkup = `
`; // 1. Append the markup to the document document.body.insertAdjacentHTML('beforeend', modalMarkup); // 2. Select the elements we just created const modalRoot = document.getElementById('window-modal'); const closeBtn = modalRoot.querySelector('.crayons-modal__dismiss'); const backdrop = modalRoot.querySelector('.crayons-modal__backdrop'); // 3. Define the remove function const closeModal = () => { modalRoot.remove(); }; // 4. Add Event Listeners // Close when the 'X' button is clicked if (closeBtn) { closeBtn.addEventListener('click', closeModal); } // Close when the background overlay is clicked if (backdrop) { backdrop.addEventListener('click', closeModal); }