Issue
I am trying to set up cookies that expire in 7 days after clicking the 'x' on the modal. I can't figure out why it doesn't want to save the cookie. Below is the code I am using. The site is goodbooks.io.
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"> </script>
<script>
var cookieName = 'popupClosed';
if(typeof Cookies.get(cookieName) !== 'undefined') {
$('.popup-wrapper, .preview-page, .popup-content-wrapper, .popup').remove();
}
$('.close-popup').on('click'), function(){
Cookies.set(cookieName, 'value', { expires: 7});
}
</script>
Solution
Change
$('.close-popup').on('click'), function(){ ... }
to
$('.close-popup').on('click', function(){ ... })
Answered By - Rocky Sims
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.