将Cookie设置为仅播放动画一次(jquery) [英] Set cookie to only play animation once (jquery)

查看:178
本文介绍了将Cookie设置为仅播放动画一次(jquery)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动画,我正在使用jQuery。我假设一个好的方法只有播放这个动画一次为访客是通过设置一个cookie。我基本上需要它说你已经在这里,所以设置所有的ID列出到不透明度:1是否有一个超简单的解决方案?感谢任何帮助

I have an animation that I am running using jQuery. I am assuming a good way to only play this animation once for the visitor is by setting a cookie. I basically need it to say you've been here before so set all the IDs listed to opacity:1 Is there an ultra simple solution to this? Thanks for any help

  $(document).ready(function(){
    $("#featureFade").animate({opacity:1},400,function(){
        $("#image").delay(300).animate({opacity:1},300,function(){
        $("#title").delay(300).animate({opacity:1},300,function(){
        $("#message, #move").delay(200).animate({opacity:1},300,function(){ 
            $("#move").animate({top: '400px',left: '0px'}, 500,function(){
            $("#nav,#contentContainer,#button,#footer,#topLevelNav").delay(1000).animate({opacity:1},700);
                });
                });
                });
            });
    });
});


推荐答案

使用 jQuery Cookie Plugin 您可以这样做:

// check for previous visit
if ($.cookie('hasSeenAnimation') == null){
  // ...
  // play animation
  // ...

  // set cookie to stop next visit
  $.cookie('hasSeenAnimation','true');
}

这篇关于将Cookie设置为仅播放动画一次(jquery)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆