利用定时器
setInterval(function(){
var oDate=new Date();
var hours=oDate.getHours();
var minutes=oDate.getMinutes();
function transform(params){
return params=params<10?"0"+params:params
}
document.getElementById("time").innerHTML=transform(hours)+":"+transform(minutes)
},1000)
<p id="time">21:32</p>