利用數(shù)組和提取split()方法來解決,供大家參考
<script type="text/javascript">
? var attime;
? function clock(){
? ? var time=new Date();
? ? var myarr=time.split(" ");
? ? attime=myarr[4];
? ? document.getElementById("clock").value = attime;
? }
? setInterval(clock,1000);
</script>
2021-09-26
good!