I have a code show popup on the website, I want this popup only show 1 once/day for user. I use the code below to show the popup:
For functions theme flatsome:
function img_popup(){;?> <div class="btn-popup"> <div class="before-img"></div> <div class="img-popup"> <a href=""> <img src="link-images"> </a> </div> </div> <?php } add_action('flatsome_footer','img_popup');
For js:
<script> jQuery(document).ready(function ($) { function show_popup(){ $(".btn-popup").show(); }; window.setTimeout( show_popup, 5000 ); // 5 seconds $(".btn-popup .before-img").on("click", function(e){ $(".btn-popup").addClass('hide-imt'); }); }); </script>
Please help me, thanks.
Advertisement
Answer
if (!localStorage.getItem("lastSet")) { // your logic here localStorage.setItem("lastSet", new Date().getTime()) }