function time()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
h=addzero(h);
m=addzero(m)
s=addzero(s)
document.getElementById(“控件的ID”).innerHTML=h+":"+m+":"+s
t=setTimeout(time()',1000) // 利用递归的方法去反复的调这个方法,来实现秒的 动态变化!
}
function addzero(i) //当秒是1-9的时候,数据比较单一,在前面加个零
{
if (i<10)
{i="0" + i}
return i
}
</script>