请教一下,想让onclick点击后停止执行tran(),方法函数该如何写?
<div id='time'></div>
<button onclick="stop()"></button>
<script type="text/javascript">
var a = 0;
function tran(){
var time = document.getElementById('time');
time.innerHTML = a++;
window.setTimeout('tran()',1000);
}
window.setTimeout('tran()',1000);
</script>