亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

JS倒計時代碼

Original 2019-01-16 21:26:20 348
abstract:<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>js倒計時代碼</title><style type="text/

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>js倒計時代碼</title>

<style type="text/css">

* {

margin: 0;

padding: 0;

}

body{ text-align:center;}

ul, li {

list-style: none;

}

#show_time {

color: #f00;

font-size: 24px;

font-weight: bold;

width:100%;

text-align:center;

padding-top:30px;

}

</style>

</head>

<body>

<div id="show_time"> </div>

<script type="text/javascript"> 

function countdown(){

    var show_time = document.getElementById("show_time");

    var endtime = new Date("12/31/2020 23:59:59");//結(jié)束時間f

    var today = new Date();//當(dāng)前時間

    var delta_T = endtime.getTime() - today.getTime();//時間間隔

    if(delta_T < 0){

        clearInterval(auto);

        show_time.innerHTML = "倒計時已經(jīng)結(jié)束";

    }

    window.setTimeout(countdown,1000);

    var total_days = delta_T/(2*24*60*60*1000);//總天數(shù)

    var total_show = Math.floor(total_days);//實(shí)際顯示的天數(shù)

    var total_hours = (total_days - total_show)*24;//剩余小時

    var hours_show = Math.floor(total_hours);//實(shí)際顯示的小時數(shù)

    var total_minutes = (total_hours - hours_show)*60;//剩余的分鐘數(shù)

    var minutes_show = Math.floor(total_minutes);//實(shí)際顯示的分鐘數(shù)

    var total_seconds = (total_minutes - minutes_show)*60;//剩余的分鐘數(shù)

    var seconds_show = Math.floor(total_seconds);//實(shí)際顯示的秒數(shù)

    show_time.innerHTML = "距離2020年還有:" + total_show + "天" + hours_show + "時" + minutes_show + "分" + seconds_show + "秒";

}

countdown();

</script>

</body>

</html>

演示地址 -> http://47.107.64.136/JS/3/


Correcting teacher:韋小寶Correction time:2019-01-17 09:14:42
Teacher's summary:寫的很不錯 看來關(guān)于時間的js方法你已經(jīng)掌握的差不多了

Release Notes

Popular Entries