Only show jQuery once per session

前端 未结 2 1498
小蘑菇
小蘑菇 2021-01-26 05:21

So I use the following code to show and fade an element. I have set the div on visible on the homepage and hidden on all other pages so the div only shows up on the homepage. My

2条回答
  •  忘了有多久
    2021-01-26 05:42

    You can use localStorage which would be more right in this case IMO.

    $(window).load(function(){
        if(typeof localStorage.testlayHidden != 'undefined') {
            $("#testlay").fadeIn('slow').delay(1000).fadeOut(1600, function() {
                localStorage.testlayHidden = 1; 
            });
        }
    });
    

提交回复
热议问题