<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<link rel="stylesheet" href="">
<style>
*{
margin:0px;
padding: 0px;
}
.a{
position: absolute;
left: 50%;
top: 50%;
margin-left: -250px;
margin-top: -25.5px;
width: 500px;
height: 55px;
background-color: #0f0;
border:1px solid #000;
border-radius:50px;
text-align: center;
line-height: 55px;
}
</style>
</head>
<body>
<div class="a">
<span id="str">sadsadsada</span>
</div>
<script>
//定时器
function date(){
strobj=document.getElementById('str')
dobj=new Date();
h=dobj.getHours();
y=dobj.getFullYear();
m=dobj.getMonth()+1;
d=dobj.getDate();
s=dobj.getSeconds();
M=dobj.getMinutes();
strobj.innerHTML=y+'-'+m+'-'+d+'-'+h+'-'+M+'-'+s;
}
date();
s1=setInterval(date,1000);
//clearInterval(s1);清除定时器;
</script>
</body>
</html>
js定时器实例
最新推荐文章于 2024-02-03 13:07:31 发布