I am creating a JavaScript popup. The code is as below.
The Issue:
The script below works fine, but I need to make the popUp to appear only once on my page. i.e, when the user closes the popup, it should not appear until the user restarts the browser or clears his cache/cookie.
I know there are similar questions but I couldn't find an answer that was using the same script I'm using so I apologize in advance. Please help!
$(document).ready(function() {
$("#popup").hide().fadeIn(1000);
$("#close").on("click", function(e) {
e.preventDefault();
$("#popup").fadeOut(1000);
});
});
#popup {
display: none;
position: absolute;
margin: 0 auto;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
box-shadow: 0px 0px 50px 2px #000;
}
body {
background: url('http://i.imgur.com/kO2Ffje.png?1') center top;
width: 100%;
height: 100%;
margin: 0 auto;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="popup" class="popup panel panel-primary">
<img src="http://i.imgur.com/cVJrCHU.jpg" alt="popup">
<div class="panel-footer">
<button id="close" class="btn btn-lg btn-primary">Close button</button>
</div>
</div>