在规定的时间内出现动画.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <div id="mammonImg" class="mammonImg">
            <img src="img/mammon.png"/>
        </div>
    </body>
    <script>
        var _cammon = {};
        _cammon.animation = function(){
                //判断手机当前日期如果大于或者等于2017年1月27日并且小于2017年2月3日显示动画
                if(_cammon.getNowFormatDate() >= "20170127" && _cammon.getNowFormatDate() < "20170204"){
                    
                    var lUserId = Number(getStringValue("lUserId")); //获取用户ID    
                    var yearDayDate = getStringValue(_cammon.getNowFormatDate()+lUserId);//获取当前存的K值
                    //判断当前日期K值不存在就显示动画
                    if(yearDayDate == "" || yearDayDate == undefined || yearDayDate == null){
                        setTimeout(function(){
                            $("#mammonImg").addClass("cammonAnimation");
                        },500);
                        setTimeout(function(){
                            $("#mammonImg").removeClass("cammonAnimation");
                            $("#mammonImg").addClass("cammonAnimation1").show();  //360旋转
                        },3000);
                        
                        setTimeout(function(){
                            $("#mammonImg").removeClass("cammonAnimation1");
                            $("#mammonImg").addClass("cammonAnimation2");
                        },7000);
                        
                        setTimeout(function(){
                            $("#mammonImg").hide();
                        },8000);
                        //保存当前日期的K值
                        setStringValue(_cammon.getNowFormatDate()+lUserId, _cammon.getNowFormatDate()+lUserId);
                    }
            }
        };
        _cammon.getNowFormatDate = function(){
        
               var date = new Date();
               var seperator1 = "-";
               var year = date.getFullYear();
               var month = date.getMonth() + 1;
               var strDate = date.getDate();
               if (month >= 1 && month <= 9) {
                   month = "0" + month;
               }
               if (strDate >= 0 && strDate <= 9) {
                   strDate = "0" + strDate;
               }
               var currentdate = year + month + strDate;
               return currentdate;
        };

    </script>
</html>
原文地址:https://www.cnblogs.com/binmengxue/p/6364495.html