定时器
来源:互联网 发布:淘宝女装店推荐高品质 编辑:程序博客网 时间:2024/06/15 14:56
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>通过定时器显示当前时间</title>
<script>
var s;
window.onload=function(){
s = window.setInterval("shijian()",1000)
}
function shijian(){
var sdom = document.getElementById("spantime");
var now = new Date();//用来得到当前时间
var stime = now.getFullYear()+"年"+(now.getMonth()+1)+"月"
+now.getDate()+"日"+now.getHours()+"时"
+now.getMinutes()+"分"+now.getSeconds()+"秒";
sdom.innerHTML=stime;
}
function tingzhi(){
window.clearInterval(s);//停止定时器
}
function kaishi(){
s=window.setInterval("shijian()",1000)
}
</script>
</head>
<body>
<span id="spantime"></span>
<input type="button" value="停止" onclick="tingzhi()">
<input type="button" value="开始" onclick="kaishi()">
</body>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>通过定时器显示当前时间</title>
<script>
var s;
window.onload=function(){
s = window.setInterval("shijian()",1000)
}
function shijian(){
var sdom = document.getElementById("spantime");
var now = new Date();//用来得到当前时间
var stime = now.getFullYear()+"年"+(now.getMonth()+1)+"月"
+now.getDate()+"日"+now.getHours()+"时"
+now.getMinutes()+"分"+now.getSeconds()+"秒";
sdom.innerHTML=stime;
}
function tingzhi(){
window.clearInterval(s);//停止定时器
}
function kaishi(){
s=window.setInterval("shijian()",1000)
}
</script>
</head>
<body>
<span id="spantime"></span>
<input type="button" value="停止" onclick="tingzhi()">
<input type="button" value="开始" onclick="kaishi()">
</body>
</html>
显示当前时间,有停止和开始两个按钮
0 0
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 定时器
- 二十分钟学会Javascript初级语法
- bitmap转换与处理相关工具类,Bitmap与DrawAble与byte[]与InputStream之间的转换
- NFC读取卡号学习
- orr r0,r0,#R1_nF:OR:R1_iA
- 体育竞技游戏的团队AI
- 定时器
- webpack系列译文(1)
- Java的异常处理的方式
- string类函数
- 玩转AppBarLayout,更酷炫的顶部栏
- 正则表达式--start end
- C语言通信处理函数
- 单击按钮替换内容
- HDU-2008