By default, when you open an Elementor popup and then use that popup to open another, both popups will remain on the screen. This code snippet closes the original popup to prevent both popups from showing simultaneously.
Scenario
Popup A has a link to Popup B, and both serve different purposes, so you don’t want them displayed simultaneously.
Implementation
The steps below are for the initial popup you want to close.
- Edit your Elementor Popup template.
- Add the HTML widget anywhere within the template, as it won’t display on the front end of your website.
- Save changes.
<script>
jQuery(function ($) {
$(document).on("click", ".elementor-location-popup a", function (event) {
elementorProFrontend.modules.popup.closePopup({}, event);
});
});
</script>