# Close an Elementor Popup After Its Form Is Sent

> Closes the Elementor Pro popup a few seconds after the form inside it is submitted successfully, so visitors see the thank-you message and then return to the page.

- Type: HTML
- Runs: Site-wide footer
- Category: [Page Builders & Themes](https://wpide.com/library/category/page-builders/)
- Tags: elementor, popups, forms
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/elementor-popup-close-after-submit/

## Code

```html
<script>
window.addEventListener('DOMContentLoaded', function () {
    var delay = 2500; // Time to show the success message first.
    if (!window.jQuery) { return; }
    window.jQuery(document).on('submit_success', function (event) {
        var form = event.target;
        var modal = form && form.closest ? form.closest('.elementor-popup-modal') : null;
        if (!modal) { return; }
        setTimeout(function () {
            var close = modal.querySelector('.dialog-close-button');
            if (close) { close.click(); }
        }, delay);
    });
});
</script>
```

## Notes

Change the delay (in milliseconds) at the top of the script.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Close an Elementor Popup After Its Form Is Sent" in its snippet library and add it in one click; or create a new HTML snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
