<script type="text/javascript"> var attime; function clock(){ var time=new Date(); var miao= time.getSeconds(); miao= miao<10 ? '0'+ miao : miao; attime= time.getHours()+':'+time.getMinutes()+':'+miao; document.getElementById("clock").value = attime; } window.onload=function(){setInterval("clock()",1000);} </script>
这样是不是更简洁呢?