WordPress
HTML
CSS
JavaScript
jQuery
SQL
PHP
WordPress Snippets

Code Snippet

When creating a popup in Elementor it can be given a button using the button widget for closing the popup. A simple link can also be created and JavaScript can be used to close it.

HTML and JavaScript

The following creates a simple link using the HTML a tag with a class of .close_sales_popup. Place this wherever you want the close link to appear.

				
					<a class="close_sales_popup">Close Popup</a>
				
			

Then the following can be placed in the head of the document or better yet linked to and placed in an external .js file. The second line of the script looks for the link with the class .close_sales_popup, and on click, closes the open popup.

				
					jQuery(function($) {
    $(document).on('click','.close_sales_popup', function(event) {
        elementorProFrontend.modules.popup.closePopup( {}, event);
    });
});
				
			

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.

WordPress
HTML
CSS
JavaScript
jQuery
SQL
PHP

Why 1SMARTchicken?

This site was built and is maintained to benefit my autistic son.
See More →

My Son's Name is Johnny

He was diagnosed as autistic quite late, at age four...
His story

Buy Me a Coffee

Thanks for your support!

Feedback

If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.