码迷,mamicode.com
首页 > 编程语言 > 详细

javascript平时小例子③(setInterval使用1)

时间:2016-11-10 11:40:40      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:body   gets   asc   class   char   head   center   ann   tin   

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.lala{
text-align: center;
}
</style>
</head>
<body>
<div class="lala">
<input type="button" value="当前时间" onclick="anniu()"/ style="width: 80px;height: 20px;" >
<input type="text" id="xi"/>
<script>


setInterval(function anniu(){
var oDate = new Date();
var oyear=oDate.getFullYear();
var month=oDate.getMonth()+1;
var day=oDate.getDate();
var hours=oDate.getHours();
var minutes=oDate.getMinutes();
var seconds=oDate.getSeconds();

document.getElementById("xi").value=oyear+"年"+month+"月"+day+"日"+hours+"时"+minutes+"分"+seconds+"秒"
},1000);




</script>
</div>
</body>

</html>

javascript平时小例子③(setInterval使用1)

标签:body   gets   asc   class   char   head   center   ann   tin   

原文地址:http://www.cnblogs.com/cxy66/p/6050245.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!