Hey everyone, I've been experimenting with the JavaScript on this codepen and I'm trying to make it so that when you click the background, the modal closes. However, I've run into two issues:
- The .modal is contained within .modal-background
- I'm new to this and can't figure out a workaround
Can anyone provide some guidance? I'm eager to learn and fix this issue. :)
Below is the JavaScript code that I'm working with:
$('.button').click(function(){
var buttonId = $(this).attr('id');
$('#modal-container').removeAttr('class').addClass(buttonId);
$('body').addClass('modal-active');
})
$('#modal-container').click(function(){
$(this).addClass('out');
$('body').removeClass('modal-active');
});
Thank you for your help! :D