Skip to content

Instantly share code, notes, and snippets.

@Olein-jp
Created January 25, 2020 00:06
Show Gist options
  • Save Olein-jp/c67993f81f3709154e7f9770525decf4 to your computer and use it in GitHub Desktop.
Save Olein-jp/c67993f81f3709154e7f9770525decf4 to your computer and use it in GitHub Desktop.
<div id="modal-id" class="modal modal-open">
<button class="modal-close">X</button>
</div>
$('.modal-open').each( function(){
$(this).on( 'click', function(){
var target = $(this).data( 'target' );
var modal = document.getElementByID( target );
$(modal).fadeIn();
// if you'd like to change diplay property to 'inline-block' or 'flex', write below
// $(modal).fadeIn().css( 'display', 'flex' );
return false;
});
});
$('.modal-close').on( 'click', function(){
$('.modal').fadeOut();
});
<a href="#" data-target="modal-01">
<!-- Open modal if you click this aea -->
</a>
<a href="#" data-target="modal-02">
<!-- Open modal if you click this aea -->
</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment