<html>
<head>
<title>JS练习</title>
<script>
function clock()
{
var tt = new Date();
document.getElementById("time").innerHTML = tt.getHours()+":"+
(tt.getMinutes()<10?"0"+tt.getMinutes():tt.getMinutes())+":"+(tt.getSeconds()<10?"0"+tt.getSeconds():tt.getSeconds());
}
setInterval("clock()",500);
</script>
</head>
<body>
<div id="time"></div>
</body>
</html>