亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

w3schools 倒計時器:為什么我的 index.html 文件打開時顯示的是空白頁面而不是

w3schools 倒計時器:為什么我的 index.html 文件打開時顯示的是空白頁面而不是

Qyouu 2023-08-18 14:10:21
  <!DOCTYPE HTML>    <html>    <head>      <meta name="viewport" content="width=device-width, initial-scale=1">      <style>        p {          text-align: center;          font-size: 60px;          margin-top: 0px;        }      </style>      </head>      <body>          <p id="timer"></p>          <script>      // Set the date we're counting to      var countDownDate = new Date("Nov 19, 2020 13:00:00").getTime();      // Update the countdown every second      var updateEverySecond = setInterval(function() {        // Get today's date and time        var now = new Date().getTime();        // Find the remaining time between now and the count down date        var remaining = countDownDate - now;        // Time calculations for days, hours, minutes, and seconds        var days = Math.floor(remaining / (1000 * 60 * 60 * 24));        var hours = Math.floor((remaining % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));        var mins = Math.floor((remaining % 1000 * 60 * 60)) / (1000 * 60));        var sec = Math.floor((remaining % (1000 * 60)) / 1000);        // Output the result in an element with id="timer"      document.getElementById("timer").innerHTML = days + "d " + hours + "h "        + mins + "m " + sec + "s ";        // If the countdown is over, display a message        if (remaining < 0) {          clearInterval(updateEverySecond);     document.getElementById("timer").innerHTML = "EXPIRED";        }      }, 1000);      </script>        </body>    </html>以上是我的index.html文件的內容。這是我關注的 w3schools 頁面的鏈接: https://www.w3schools.com/howto/howto_js_countdown.asp 我嘗試在項目目錄中創建一個 server.js 文件,我可以包含該內容文件,或任何其他文件,如果這可以澄清我的問題。任何幫助表示贊賞!
查看完整描述

2 回答

?
小唯快跑啊

TA貢獻1863條經驗 獲得超2個贊

更改線路

var mins = Math.floor((remaining % 1000 * 60 * 60)) / (1000 * 60));

對此

var mins = Math.floor((remaining % (1000 * 60 * 60)) / (1000 * 60));

它會起作用的


查看完整回答
反對 回復 2023-08-18
?
守候你守候我

TA貢獻1802條經驗 獲得超10個贊

如果您從網站復制整個代碼,并將其粘貼到您的 HTML 文檔中,它應該可以工作。如果這不起作用,則不要將文件命名為“index.html”,有時文件可能會覆蓋



查看完整回答
反對 回復 2023-08-18
  • 2 回答
  • 0 關注
  • 160 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號