When writing your own form of communication and using the Magnific Popup library, a situation can arise when the communication form is successfully sent, but the popup remains unclosed and disturbs the site visitor. It is much more natural if the form displays a message about successful sending and closes itself after 2-3 seconds.
You can do this with a simple function $.magnificPopup.close()
, such as this:
setTimeout(function() {
$.magnificPopup.close();
}, 2500);
You can also use this function to close the popup when you click on an arbitrary button.
$('.close-my-popup').click(function() {
$.magnificPopup.close();
});