Skip to content

Instantly share code, notes, and snippets.

@imlinus
Last active January 8, 2018 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imlinus/d63697a518c6c3c77a817b13947589b8 to your computer and use it in GitHub Desktop.
Save imlinus/d63697a518c6c3c77a817b13947589b8 to your computer and use it in GitHub Desktop.
Simple as cake modal
<div class="modal" data-modal-id="foo">
<span onclick="Modal.close('foo')">&times;</span>
<p>Lorem ipsum..</p>
</div>
<script>
Modal.open('foo')
</script>
var Modal = {
open: function(id) {
document.querySelector('.modal[data-modal-id="' + id + '"]').classList.add('active')
},
close: function(id) {
document.querySelector('.modal[data-modal-id="' + id + '"]').classList.remove('active')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment