<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>考勤管理</title>
<style>
.round-button {
background-color: #4CAF50;
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
width: 100px;
height: 100px;
line-height: 100px;
border-radius: 50%;
cursor: pointer;
}
</style>
</head>
<body>
<button id="checkInButton" class="round-button">
<span id="timeDisplay"></span>
</button>
<script>
function getNowTime () {
let now = new Date();
let year = now.getFullYear();
let month = now.getMonth() + 1;
let today = now.getDate();
let hour = now.getHours();
let minute = now.getMinutes();
let second = now.getSeconds();
let nowTime = ''
nowTime = fillZero(hour) + ':' + fillZero(minute) + ':' + fillZero(second)
return nowTime
};
function fillZero (str) {
var realNum;
if (str < 10) {
realNum = '0' + str;
} else {
realNum = str;
}
return realNum;
}
console.log(getNowTime())
function updateTime() {
const now = new Date();
const hours = now.getHours();
const timeDisplay = document.getElementById('timeDisplay');
if (hours >= 9 && hours < 18) {
timeDisplay.textContent = '上班打卡';
} else {
timeDisplay.textContent = '下班打卡';
}
timeDisplay.textContent = timeDisplay.textContent+getNowTime ();
}
function showAlert() {
alert('打卡成功');
}
document.getElementById('checkInButton').addEventListener('click', showAlert);
updateTime();
setInterval(updateTime, 1000);
</script>
</body>
</html>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异