Stop executing script on close div with jquery?

I got this script that pops up a div on user scroll and shows it all the time.

I would like to add close button to hide div when clicked but the problem is how do I stop this code from pooing div again on same session?

$(document).ready(function(){
    $(window).scroll(function(){
    var scrollTop = $(window).scrollTop();
   // now on the basis of scrollTop value show your div
     if(scrollTop > 1){
      $('#PopupSignBut').fadeIn('slow');
     }
        
    })
});
<div id=\"PopupSignBut\">
some content
</div>

To close this I this this would do?

$("button").click(function(){
  $("#PopupSignBut").css("display","none");
});

Please help me out with this one.

So lets do some basic flagging.

var showthepopup = true;

$("button").click(function(){
  showthepopup = false;
  $("#PopupSignBut").css("display","none");
});

$(document).ready(function(){
    $(window).scroll(function(){
    var scrollTop = $(window).scrollTop();
   // now on the basis of scrollTop value show your div
     if(scrollTop > 1 && showthepopup && $("#PopupSignBut").css("display") === "none") {
      $('#PopupSignBut').fadeIn('slow');
     }
        
    })
});

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.