Write a jQuery plugin for modal window component. Take HTML and CSS from here. So it might look something like the following.
<button type=”button” data-modal=”example-modal”>Open Modal</button>
// modal html goes here
- Initialize the plugin on load if element has [data-modal] attribute
- Close modal when clicked outside the modal window or key ESCAPE is pressed
Use this link as a guide.
Originally published at tsukuros.com on March 6, 2017.