How to close popup by pressing "submit" button within a popup.

I need to find a way to close a popup other than pressing the "X" in the upper right hand corner of the screen. I would like to have the popup close when a user presses the submit button (built into the popup).

I have tried this recommendation from Vinod Dalvi with no success:

" To hide the first pop up when the user clicks submit button then try adding the following code in the functions.php file of your child theme."

function add_custom_scripts(){ ?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#e2ma_signup_submit_button").click(function(){
jQuery(this).parent(".wdpu-container").hide();
});
});
</script>
<?php }
add_action('wp_footer', 'add_custom_scripts');

Thank you!
Toni