<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<button type="button" onclick="startRefresh()">开始刷新</button>
<button type="button" onclick="stopRefresh()">关闭刷新</button>
<p style="color: red" id="dt"></p>
<script type="text/javascript">
function refresh() {
x=document.getElementById("dt");
x.innerHTML = new Date();
}
//启动刷新
function startRefresh() {
interval = setInterval("refresh()",1000)
}
//关闭刷新
function stopRefresh() {
clearInterval(interval)
}
</script>
</body>
</html>