<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>js计时器</title>
<style>
.clock{
width: 100px;
height: 25px;
background: #000;
color: #0f0;
font-weight: bold;
border-radius: 50px;
text-align: center;
line-height: 25px;
}
</style>
</head>
<body>
<div class="clock" >
<span id="spanid"></span>
<button id="bid" >停止</button>
<button id="bid2">开始</button>
</div>
</body>
<script>
//获取时间函数
function getDate(){
time=new Date();//得到日期对象,并赋值给变量time
nian=time.getFullYear();//得到年份
yue=time.getMonth()+1;//js里面月份是从0-11,的所以应该+
<html>
<head lang="en">
<meta charset="UTF-8">
<title>js计时器</title>
<style>
.clock{
width: 100px;
height: 25px;
background: #000;
color: #0f0;
font-weight: bold;
border-radius: 50px;
text-align: center;
line-height: 25px;
}
</style>
</head>
<body>
<div class="clock" >
<span id="spanid"></span>
<button id="bid" >停止</button>
<button id="bid2">开始</button>
</div>
</body>
<script>
//获取时间函数
function getDate(){
time=new Date();//得到日期对象,并赋值给变量time
nian=time.getFullYear();//得到年份
yue=time.getMonth()+1;//js里面月份是从0-11,的所以应该+