When you use an Elementor popup as a mobile menu, it often stays open after a visitor taps a link, which feels clunky. This guide adds a small script so the popup closes automatically when any link inside it is clicked, giving smoother navigation.
Need your Elementor popup menu to close automatically when someone clicks a link inside it? In this tutorial, I’ll show you exactly how I solved that problem with a simple custom script. By default, Elementor’s popups are great for mobile menus and call-to-action panels, but they can feel clunky when the popup stays open after a user chooses a menu item.
In this post, we’ll walk through the logic behind closing the popup on link click, look at the code I used, and see how you can adapt it to your own layout. You’ll learn where to place the code, how it interacts with Elementor’s popup settings, and how to make sure it works smoothly on both desktop and mobile.
Whether you’re building a fullscreen mobile menu or a small popup navigation, this quick tweak will make your site feel more polished and user-friendly — no extra plugins required.
<script>
jQuery(function($){
$(document).on(‘click’,’.elementor-location-popup a’, function(event){
elementorProFrontend.modules.popup.closePopup( {}, event);
});
});
</script>
How it works
The script listens for clicks on links inside the popup and triggers the Elementor close action for that popup. Because it uses the popup id, it targets only the menu you want and leaves other popups untouched.
Tips and customization
- Match the popup id in the code to your own popup.
- Apply it to any menu style, not just hamburger menus.
- Test on mobile to confirm the close feels natural.
FAQ
Does this need Elementor Pro?
Popups are a Pro feature, so you need Pro to create the popup, but the closing script itself is just JavaScript.
Will it close other popups?
No. It targets only the popup id you specify.
