How to Create Custom Dynamic Popups in Elementor with CSS & JS

Custom Popup Design in Elementor using CSS
Custom Popup Design in Elementor using CSS

Steps 1 to Create Dynamic Popups JS

				
					<script data-minify="1" src="https://mojibur.com/wp-content/cache/min/1/ajax/libs/jquery/3.6.4/jquery.min.js?ver=1740383262" data-rocket-defer defer></script>
<script>window.addEventListener('DOMContentLoaded', function() {
$(document).ready(function() {
  $(".pop1img").click(function() {
    $(".pop1").show();
  });
});

$(document).ready(function() {
  $(".close").click(function() {
    $(".pop1").hide();
  });
});
});</script>

				
			

Steps 2 to Create Dynamic Popups CSS

				
					.pop1{
display:none;
}

.pop1img {
cursor: pointer;
}

.close{
cursor: pointer;
transition: width .6s, height .6s, transform .3s;
}
.close:hover {
transform: rotate(-45deg);
}
				
			

Alternative Optimized Code Using .toggle()
If you want to toggle the visibility instead of always showing/hiding:

				
					<script>window.addEventListener('DOMContentLoaded', function() {
$(document).ready(function(){
    $(".pop1img").click(function(){
        $(".pop1").toggle(); // Toggles visibility
    });

    $(".close").click(function(){
        $(".pop1").hide(); // Hides when clicking close
    });
});
});</script>
				
			

Optimized code for multiple Popups JS

				
					<script data-minify="1" src="https://mojibur.com/wp-content/cache/min/1/ajax/libs/jquery/3.6.4/jquery.min.js?ver=1740383262" data-rocket-defer defer></script>
<script>window.addEventListener('DOMContentLoaded', function() {
$(document).ready(function() {
  
  for (let i = 1; i <= 8; i++) {
    $(`.popst${i}`).click(function() {
      $(`.pop${i}`).css('display', 'flex');
    });
  }

  // Handle close event for all popups
  $(".close").click(function() {
    $(".pop1, .pop2, .pop3, .pop4, .pop5, .pop6, .pop7, .pop8").hide();
  });
});
});</script>
				
			

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest tutorials

Freelancer Mojibur
freelancer mojibur

Start a Project!

Interested in working together? Send a quick message or schedule a meeting. Ask questions, discuss details, and decide if we are a good fit.

Website Project Inquiry

This form helps me get a general idea. We’ll schedule a meeting soon to discuss everything in more detail!

Freelancer Mojibur

Contact person

For quick communication email at: freelancermojibur@gmail.com