欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript電商網(wǎng)站搶購倒計時效果實現(xiàn)

 更新時間:2015年11月19日 09:32:36   投稿:lijiao  
這篇文章主要介紹了javascript電商網(wǎng)站搶購倒計時效果實現(xiàn)代碼,掌握日期對象Date,獲取時間的方法,感興趣的小伙伴們可以參考一下

本文實例講述了javascript電商網(wǎng)站搶購倒計時效果實現(xiàn)代碼。分享給大家供大家參考。具體如下:
運行效果截圖如下:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>團購——限時搶</title>

</head>

<body>

<div class="time"> <span id="LeftTime"></span></div>
</div>
<script>
function FreshTime()
{
    var endtime=new Date("2015/11/20,12:20:12");//結(jié)束時間
    var nowtime = new Date();//當(dāng)前時間
    var lefttime=parseInt((endtime.getTime()-nowtime.getTime())/1000); 
    d=parseInt(lefttime/3600/24);
    h=parseInt((lefttime/3600)%24);
    m=parseInt((lefttime/60)%60);
    s=parseInt(lefttime%60);

    document.getElementById("LeftTime").innerHTML="還剩" + d+"天"+h+"小時"+m+"分"+s+"秒";
    if(lefttime<=0){
        document.getElementById("LeftTime").innerHTML="團購已結(jié)束";
        clearInterval(sh);
    }
}
    FreshTime();
    var sh;
    sh=setInterval(FreshTime,1000);
</script>
</body>
</html>

很簡單的團購限時搶購倒計時,特別適合用于現(xiàn)今團購網(wǎng)、電商網(wǎng)、門戶網(wǎng)等倒計時搶購活動,希望本文能幫助大家熟練掌握javascript倒計時效果的實現(xiàn)方法。

相關(guān)文章

最新評論