等待1s后变大变宽,可还原

原创 2018-11-13 14:43:20 206
摘要:<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>Document</title></head><body> <div style="width: 100px;height

QQ图片20181113144144.pngQQ图片20181113144155.png<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
 <title>Document</title>
</head><body>
 <div style="width: 100px;height: 100px;
 background: red;border: 1px solid #ccc;margin:50px 60px" id="box">
    </div>
  <input type="button" value="开始变大" onclick="aa()">
    <input type="button" value="暂停" onclick="bb()" >
    <input type="button" value="还原" onclick="cc()" >
   <script type="text/javascript">
 var box,trop;
 var  hei=100;
 var wid=100;
 window.onload=function(){
  box=document.getElementById('box');
 }
 function mygetTime(){
  var now=100;
  var date=new Date();
  var contime=date.getTime()+now;
    while(true){
    var date1=new Date();
  var contime1=date1.getTime();
   if(contime1>=contime)
     return  ;
    }
}
    function aa(){
   
   
     // document.write(wid);
      mygetTime();
     var w=wid.toString()+"px";
     var h=hei.toString()+"px";     // document.write(b);
     box.style.height=h;
     box.style.width=w;
     hei+=10;
     wid+=10;
     if(hei<=200&&trop!=1){        aa();
       }
     else{
     return;
    }
   
    }
    function bb(){
     trop=1;
     aa();
     
         }
    function cc(){
     box.style.width="100px";
     box.style.height= "100px";
 }</script>
</body>
</html>

批改老师:灭绝师太批改时间:2018-11-13 15:02:40
老师总结:完成的不错,在老师的基础上有升级,继续保持……

发布手记

热门词条