知识要点
1.实现原理:
用结束时间-当前时间=时间差
当前时间每过1秒时间差自然也就少了1秒
所以要1秒更新一次当前时间就达到了倒计时的效果
2.需要注意的就是时间之间的转换和对得出数值的处理
3.用到的方法:
obj.getTime() //换算成毫秒 Math.floor() //把小数点向下舍入结果取一个整数 50%24 // 这是对数值求余的方法,意思是 假如有50个小时,一天24个小时 这个得出的结果就是 余数是2
具体的数值的运算处理完整代码里有详细的注释
完整代码
注:代码附带显示当前时间的标准格式以及倒计时天数
demo body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td{margin:0;padding:0;} h1,h2,h3,h4,h5,h6{font-size:100%;} address,cite,dfn,em,var{font-style:normal;} code,kbd,pre,samp{font-family:courier new,courier,monospace;} ul,ol{list-style:none;} a{text-decoration:none;} a:hover{text-decoration:none;} sup{vertical-align:text-top;} sub{vertical-align:text-bottom;} legend{color:#000;} fieldset,img{border:0;} button,input,select,textarea{font-size:100%;} table{border-collapse:collapse;border-spacing:0;} .clear{clear: both;float: none;height: 0;overflow: hidden;}
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持考高分网!



