javascript - Modal fade on page touch -
so i've created modal hides on exit using code:
$('#emailtoggle').on('click', function() { $('body').toggleclass('dialogopen'); }); $(document).keyup(function(e) { if($('body').hasclass('dialogopen')) { if(e.keycode == 27) $('body').toggleclass('dialogopen'); } });
i trying make when user touches outside modal, modal fade this.
i tried using:
$(document).on('click', function(){});
but had no luck..
thanks
minimal example:
css:
.overlay{ display: none; position: fixed; width: 100%; height: 100%; z-index: 3; } .modal{ z-index: 4; } .showoverlay{ display: block; }
javascript:
$('.overlay').on('click', function() { $('body').toggleclass('dialogopen'); $(this).toggleclass('showoverlay'); });
Comments
Post a Comment