How do I add a pop-up on BTN Click

I want to trigger a pop-up when a button is clicked. How can I do this on a Shopify page?

HI @kecidoklrt
To achieve this follow the below steps:

Go to Online Store > Themes > Actions > Edit code.
Open the theme.liquid file.

Add HTML for the Pop-up:

Add the following code before the closing tag:


  

    ×
    

Sign up for our newsletter!

    
  

Add CSS for Styling:

Add this to your CSS file (theme.css or styles.css):

#popup {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}

.popup-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  padding: 20px;
  border-radius: 5px;
  text-align: center;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 20px;
  cursor: pointer;
}

Add JavaScript for Functionality:

Include this JavaScript code in your theme.liquid file, just before the closing tag:

document.addEventListener('DOMContentLoaded', function () {
  var popup = document.getElementById('popup');
  var closeBtn = document.querySelector('.close-btn');
  
  setTimeout(function () {
    popup.style.display = 'block';
  }, 3000); // Show popup after 3 seconds

  closeBtn.addEventListener('click', function () {
    popup.style.display = 'none';
  });
});

Thank you

D.P.

Working thanks

Welcome @kecidoklrt! Let me know if you need any further assistance.