Join

How to Close an Elementor Popup That’s Used to Open Another Popup

Don't want to mess with code snippets? Request for this to be a feature of MyListing Pro.

Instructions

  1. Create a new HTML code snippet.
  2. Copy the contents of code snippet below.
  3. Paste the contents into your code snippet.
  4. Review any notes that I’ve provided.
  5. Save and enable the code snippet.
  6. Test.

Snippet

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.

  1. Edit your Elementor Popup template.
  2. Add the HTML widget anywhere within the template, as it won’t display on the front end of your website.
  3. Save changes.
<script>
    jQuery(function ($) {
        $(document).on("click", ".elementor-location-popup a", function (event) {
            elementorProFrontend.modules.popup.closePopup({}, event);
        });
    });
</script>