【JS】倒計時

來源:互聯網
上載者:User

標籤:

描述:

先要連結jquery.js,這樣寫法可以直接放JS檔案運行。

//放在圖片裡定位的倒計時//頂圖裡面定位才使用的代碼document.writeln("<style>");document.writeln("    .top_div1{width:100%;overflow:hidden;margin:0 auto;text-align:center;}");document.writeln("    .top_div2{");document.writeln("    text-align:center;max-width:1600px;margin:0 auto;text-align:center;background: url(/images/headerPic.jpg) no-repeat center;height:200px;");document.writeln("    }    ");document.writeln("    .top_div3{");document.writeln("    height:100px;width:100px;position:absolute;right:245px;top:40px;float:right;");document.writeln("    }");document.writeln("    </style>");document.writeln(" <div class=\"top_div1\">");document.writeln(" <a href=\"/hd_tex.html\" onclick=\"gaPush(\‘top_huodong_banner\‘); _czc.push([\‘_trackEvent\‘, \‘swt\‘, \‘top_huodong_banner\‘, \‘top_huodong_banner\‘, 0, \‘top_huodong_banner\‘]);\" target=\"_blank\">");document.writeln(" <div class=\"top top_div2\">");document.writeln(" <div id=\"div_dw\" class=\"top_div3\">");document.writeln(" <div id=\"lastDays1\" style=\"color:red;font-size:95px;font-weight: bold;line-height:70px;height:70px;margin-top:5px;font-family:黑體\"></div>");document.writeln(" <div style=\"font-size:10px;color:#000;margin-top:10px; margin-left:10px;\"><span id=\"lastHours1\">12</span>小時<span id=\"lastMin1\">23</span>分<span id=\"lastSecond1\">0</span>秒</div>    ");document.writeln(" </div>");document.writeln(" </div>");document.writeln(" </a>");document.writeln(" </div>");//以屏寬1424為準的計算var juli = 245 + ($(window).width() - 1424)/2;$("#div_dw").css("right",juli);//頂圖倒計時function ShowTOPDown(year,month,day) { var now = new Date(); var endDate = new Date(year, month-1, day); var leftTime=endDate.getTime()-now.getTime(); var leftsecond = parseInt(leftTime/1000); //var day1=parseInt(leftsecond/(24*60*60*6)); var day1=Math.floor(leftsecond/(60*60*24)); var hour=Math.floor((leftsecond-day1*24*60*60)/3600); var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60); var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);$("#lastDays1").html(day1);$("#lastHours1").html(hour);$("#lastMin1").html(minute);$("#lastSecond1").html(second);}window.setInterval(function(){ShowTOPDown(2016,01,02);}, 1000);

 

【JS】倒計時

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.