Emtag Posted October 14, 2019 Share Posted October 14, 2019 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> Link to comment
SnazzyView Posted October 14, 2019 Share Posted October 14, 2019 (edited) 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 October 14, 2019 by ThompsonWebDesign snazzyview.com Link to comment
Emtag Posted October 14, 2019 Author Share Posted October 14, 2019 Yup! Added the jquery library — no dice. Any thoughts? Link to comment
paidforbychrist Posted September 5, 2021 Share Posted September 5, 2021 I love your code! I tried it and had the same problem. My husband figured it out: The problem is the code you use to make the X on the button. If we used a <button...></button> the X only refreshes the page. Try making it an <input type=button ...> and see if that helps things along: <input type=button label='Hide popup' id='exit_popup' value='X'> Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment