Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0
Sign in to follow this  
Emtag

Creating a text box with a "close" button

Question

Hey there, 

Im trying to create a very simple box with text to go over a shop page that can be closed if the user doesn't want to see it. Everything seems to work fine except the "x" button doesnt seem to work on squarespace, though it works in the codepen (I converted the less to css). Any help would be greatly appreciated. 

Here's the code: 

<style>#popup-holder {
     position: absolute;
     top: 100px;
     height: 200px;
     width: 100%;
}
 #popup-holder.hide {
     display: none;
}
 #popup-box {
     width: 200px;
     height: 200px;
     position: relative;
     margin: 0px auto;
     background: white;
     border-style: solid;
     border-color: #1d1e21;
     border-width: 4px;
}
 #popup-box p {
     font-size: 1.5em;
     color: black;
     font-family: sans-serif;
     text-align: center;
     padding-top: 3em;
     padding-bottom: 3.5;
}
 #popup-box button {
     border-radius: 0px;
     border: none;
     background: transparent;
     font-size: 2em;
     color: black;
     position: absolute;
     right: 0;
     top: 0;
     cursor: pointer;
     padding: 2px 15px 8px 15px;
}
 #popup-box button:hover, #popup-box button:focus {
     background: rgba(255,255,255,0.4);
}
 .page-article {
     background-color: #eee;
     width: 70%;
     margin: 30px auto;
     padding: 20px;
     font-family: sans-serif;
     min-height: 100px;
}
 .page-article a {
     color: #000;
     text-decoration: none;
}
 .page-article a:hover, .page-article a:focus {
     text-decoration: underline;
}
 </style>

 

<Script>

$('#exit-popup').click( function() {
  $('#popup-holder').addClass('hide');
  $('#pa-2 a').focus();
});

setTimeout( function() {
  $('#popup-holder').removeClass('hide');
  $('#exit-popup').focus();
}, 3000);

</script>

<html>

<div id="popup-holder" class="hide">
  <div id="popup-box">
    <p>Hi!</p>
    <button aria-label="Hide popup" id="exit-popup">x</button>
  </div>
</div>
</html>

Share this post


Link to post

2 answers to this question

Recommended Posts

  • 0

Have you loaded the jQuery library in your code? If not try adding the below to the global code injector header of your website and seeing if it works.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

 

Edited by ThompsonWebDesign

If you see an answer that was helpful please consider hitting the 121238226_Screenshot2019-11-02at14_53_39.png.0416997a5e856e0159fa1edbd624659e.png button on the right. 

Need help with your website or online store? Feel free to get in touch.

thompsonweb.design

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in to follow this  

×
×
  • Create New...