Skip to content

Instantly share code, notes, and snippets.

@wendelnascimento
Created April 2, 2019 22:52
Show Gist options
  • Save wendelnascimento/e3cefe62f8ede6f4cf6e49c83889c725 to your computer and use it in GitHub Desktop.
Save wendelnascimento/e3cefe62f8ede6f4cf6e49c83889c725 to your computer and use it in GitHub Desktop.
Modal js script
var modal = document.querySelector('.modal-container');
var btnOpen = document.querySelectorAll('.btn-open');
var btnClose = document.querySelector('.btn-close');
var modalSkin = document.querySelector('.modal-skin');
for (var i = 0; i < btnOpen.length; i++) {
btnOpen[i].addEventListener('click', function() {
modalToggle();
});
}
btnClose.addEventListener('click', function() {
modalToggle();
});
modalSkin.addEventListener('click', function() {
modalToggle();
});
function modalToggle() {
modal.classList.toggle('opened');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment