JS 간단 하고 실 용적 인 카운트다운 효과

15038 단어 카운트다운
카운트다운 효 과 를 연구 할 일이 없어 서 스스로 연습 을 했 습 니 다.
<!DOCTYPE HTML>

<html>

<head>

<meta charset="utf-8">

<title>   </title>

<meta name="Author" content="">

<meta name="Keywords" content="">

<meta name="Description" content="">

<style type="text/css">

    *{

        margin: 0;

        padding: 0;

    }

    ul,li{list-style: none;}

    #show_time{color: #f00;font-size: 24px;font-weight: bold;}

</style>

</head>

<body>

<div id="show_time">



</div>

<script type="text/javascript"> 

function countdown(){

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

    endtime = new Date("12/31/2012 23:59:59");//    

    today = new Date();//    

    delta_T = endtime.getTime() - today.getTime();//    

    if(delta_T < 0){

        clearInterval(auto);

        show_time.innerHTML = "       ";

    }

    window.setTimeout(countdown,1000);

    total_days = delta_T/(24*60*60*1000);//   

    total_show = Math.floor(total_days);//       

    total_hours = (total_days - total_show)*24;//    

    hours_show = Math.floor(total_hours);//        

    total_minutes = (total_hours - hours_show)*60;//      

    minutes_show = Math.floor(total_minutes);//        

    total_seconds = (total_minutes - minutes_show)*60;//      

    seconds_show = Math.floor(total_seconds);//       

    show_time.innerHTML = "      :" + total_show + " " + hours_show + " " + minutes_show + " " + seconds_show + " ";

}

countdown();

</script>

</body>

</html>

좋은 웹페이지 즐겨찾기