比较完整地答案
<script type="text/javascript">
setInterval(clock,1000);
var attime;
function clock(){
var time=new Date();
var hour = time.getHours()<10?"0"+time.getHours():time.getHours();
var minute = time.getMinutes()<10?"0"+time.getMinutes():time.getMinutes();
var second = time.getSeconds()<10?"0"+time.getSeconds():time.getSeconds();
attime= hour+"时:"+minute+"分:"+second+"秒";
document.getElementById("clock").value = attime;
}
</script>