I am after some help if at all possible.
I would like it so that once someone has clicked the X it wont re show the parent div when the page is reloaded or the user navigates to another page with the same popup.
I have the code below for where I started and hope I am only a little off!
Thanks in advance for any help :)
$(".banner-cta-close").click(function() {
$("body").addClass("header-banner-hide");
});
$(document).ready(function() {
if (sessionStorage["PopupShown"] != 'yes') {
ShowDialog(true);
e.preventDefault();
}
});
$("#btnClose").click(function(e) {
HideDialog();
e.preventDefault();
sessionStorage["PopupShown"] = 'yes'; //Save in the sessionStorage if the modal has been shown
});
function ShowDialog(modal) {
$('#div_with_text').hide(); // this or use css to hide the div
$('#div_with_text').delay(5000).slideDown('slow');
if (modal) {
$("#div_with_text").unbind("click");
} else {
$("#div_with_text").click(function(e) {
HideDialog();
});
}
}
function HideDialog() {
$("#div_with_text").hide();
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="div_with_text">
<div class="container">text
<div class="bannerbuttonhover" style="background: #2f358f;
color: #fff;
padding: 6px 12px;
display: inline-block;
margin-left: 20px;
border-radius: 2px;
cursor: pointer;">Sign Up now</div>
<div class="banner-cta-close">X</div>
</div>
</div>