作为程序员一定要保持良好的睡眠,才能好编程

页面弹出广告10秒后自动隐藏

发布时间:2018-02-28



JS:

此功能依赖于jquery


jq(function(){
            
            var issuccess=jq("#newyearimg")[0].complete;
            if(issuccess){

                    viewimg();
            }else{
             jq("#newyearimg")[0].onload=function(e){
                    viewimg();
          
             }
           }
         //view img
         function viewimg(){
            //当图片加载完毕后,执行操作
            jq("#newyearcontainer").animate({
                    marginTop:"0px",
            },"slow");

            setTimeout(function(){
                    jq("#newyearcontainer").animate({
                            height:"360px",
                    },"slow");
            },10000);

         } 

    });



HTML

<div id="newyearcontainer" style="background:#dc2019;margin-top:-580px;overflow:hidden;">
        <img src="/view/luntai/images/newyear75.jpg" id="newyearimg" style="width:1160px;height:580px;display:block;margin:0px auto;" />
</div>