<script type="text/javascript">
var setIntervalID;
window.onload = function () {
document.getElementById('btn1').onclick = function () {
setIntervalID = setInterval(function () {
document.getElementById('txt1').value++;
},1000)
};
document.getElementById('btn2').onclick = function () {
clearInterval(setIntervalID);
};
}
</script>
<input id="txt1" type="text" value="0">
<input id="btn1" type="button" value="开始">
<input id="btn2" type="button" value="暂停">