1 Star 0 Fork 0

mr_yichen/Javascript高级原理

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index2.html 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
mr_yichen 提交于 2024-03-01 09:39 +08:00 . 第一次提交
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="Time"></div>
<script>
/**
* 计算当年时间的倒数计时器,要求在网页上面实时动态显示“xx年还剩xx天xx时xx分xx秒”
*/
function gettime() {
let timenum = new Date("2023-01-01T00:00:00Z");
let timexian = new Date();
let dateTime = timenum - timexian
let dates = new Date(dateTime)
// 获取天
let Day = dates.getDate()
// 获取小时
let Hourse = dates.getHours()
// 获取分钟
let Minutes = dates.getMinutes()
//获取秒
let Seconds = dates.getSeconds()
return `2023年还剩${Day + 31 + 30 + 31}${Hourse}${Minutes}${Seconds}秒`
}
setInterval(() => {
let getTimes = document.querySelector("#Time")
getTimes.innerHTML = gettime()
}, 1000)
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mr-yichen/JavaScriptPlus.git
git@gitee.com:mr-yichen/JavaScriptPlus.git
mr-yichen
JavaScriptPlus
Javascript高级原理
main

搜索帮助