首页 > 代码库 > javascript平时小例子③(setInterval使用1)

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

<!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="http://www.mamicode.com/当前时间" 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=http://www.mamicode.com/oyear+"年"+month+"月"+day+"日"+hours+"时"+minutes+"分"+seconds+"秒"
},1000);




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

</html>

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