<p id="countdown" style="color: #FF0000;"></p>
<script>
// 设置目标日期,这里假设为2025年1月1日 00:00:00,你可根据需要修改
const targetDate = new Date('2024-11-01T00:00:00');
function updateCountdown() {
const now = new Date();
const difference = targetDate - now;
const days = Math.floor(difference / (1000 * 60 * 60 * 24));
const hours = Math.floor((difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((difference % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((difference % (1000 * 60)) / 1000);
const countdownElement = document.getElementById('countdown');
countdownElement.textContent = `剩余时间:${days}天${hours}小时${minutes}分钟${seconds}秒`;
}
// 首次加载页面时更新倒计时
updateCountdown();
// 每隔1秒更新一次倒计时(可根据需要调整间隔时间)
setInterval(updateCountdown, 1000);
</script>
HTML倒计时天数小时分钟秒 代码
admin
HTML源码
315
免责声明
1.软件源码资源来源于网络,如有侵权请联系我们!
2.侵权联系邮箱:48165603@qq.com 收到邮件的24小时内删帖!
3.资源开源分享均为网络资源,开源发布立场不代表本站!
4.请勿侵犯正版软件,尊重正版版权作者的劳动成果!
5.欢迎广大开发作者来本站投稿,开源鸭有你更精彩!
同类推荐
