js通过Date对象实现倒计时动画效果实例分享
来源:动视网
责编:小OO
时间:2020-11-27 20:05:20
js通过Date对象实现倒计时动画效果实例分享
js通过Date对象实现倒计时效果,具体内容如下:<;,<。DOCTYPE html>;<;html lang=";en";>;<;head>;<;meta charset=";UTF-8";>;<;title>;倒计时动画<;/title>;<;style>;p{ text-align:center;height:100px;line-height:100px;} <;/style>;<;script>;window.onload = function(){ setInterval(FreeTime。
导读js通过Date对象实现倒计时效果,具体内容如下:<;,<。DOCTYPE html>;<;html lang=";en";>;<;head>;<;meta charset=";UTF-8";>;<;title>;倒计时动画<;/title>;<;style>;p{ text-align:center;height:100px;line-height:100px;} <;/style>;<;script>;window.onload = function(){ setInterval(FreeTime。

本文主要为大家详细介绍了js通过Date对象实现倒计时动画效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能帮助到大家。
js通过Date对象实现倒计时效果,具体内容如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>倒计时动画</title>
<style>
p{
text-align:center;
height:100px;
line-height:100px;
}
</style>
<script>
window.onload = function(){
setInterval(FreeTime,1000);
}
function FreeTime(){
var curTime = Date.now();
var endTime = new Date("2017-10-26 16:00:00");
var allFreeSeconds = (endTime-curTime)/1000;
if(allFreeSeconds>0){
var freeDay = Math.floor(allFreeSeconds/(24*60*60));
var freeHour = Math.floor(allFreeSeconds/(60*60) % 24);
var freeMinute = Math.floor(allFreeSeconds/60 % 60);
var freeSecond = Math.floor(allFreeSeconds%60);
document.getElementById("nowTime").innerHTML = "剩余"+freeDay+"天"+freeHour+"时"+freeMinute+"分"+freeSecond+"秒";
}
else{
document.getElementById("nowTime").innerHTML = "已结束";
}
}
</script>
</head>
<body>
<p>
<span id="nowTime"></span>
</p>
</body>
</html>
js通过Date对象实现倒计时动画效果实例分享
js通过Date对象实现倒计时效果,具体内容如下:<;,<。DOCTYPE html>;<;html lang=";en";>;<;head>;<;meta charset=";UTF-8";>;<;title>;倒计时动画<;/title>;<;style>;p{ text-align:center;height:100px;line-height:100px;} <;/style>;<;script>;window.onload = function(){ setInterval(FreeTime。