This is a simple JavaScript project that creates a modal window for displaying additional information. The modal window can be triggered to open by clicking on elements with the class show-modal. Users can close the modal by clicking the close button, the overlay, or by pressing the 'Escape' key.
- Clicking on elements with the class show-modal opens the modal window.
- The modal can be closed by clicking the close button, the overlay, or by pressing the 'Escape' key.
- Add the show-modal class to any HTML elements that should trigger the modal.
- Clicking on the specified elements will display the modal window.
- To close the modal, either click the close button, the overlay, or press the 'Escape' key.
The code uses strict mode and consists of the following key components:
- showModal: Elements with this class trigger the display of the modal.
- closeModal: The button inside the modal to close it.
- overlay: The overlay behind the modal.
- modal: The modal window itself.
- addBtnModal(): Function to hide the modal and overlay.
- removeBtnModal(): Function to show the modal and overlay.
- Event listeners for clicks on elements with the show-modal class, the overlay, and the close button.
- An event listener for the 'Escape' key to close the modal.
Author -@ahmadfed
Feel free to customize this code for your needs or use it as a starting point for creating modal windows in your projects!
Contact me