HTML部分
<input type="text" id="clock" size="50">
<button onclick="test = window.clearInterval(test)">stop Interval</button>
逻辑部分
var test = self.setInterval(clock,50)
// 此处self指window
function clock(){
var time = new Date()
document.getElementById('clock').value = time
}