setInterval ---下计时器
<script> $(function(){ var n=0; function run(){ n=n+1; document.title=n; //浏览器标签栏显示标题 } setInterval(run,2000); }); </script>
clearInterval ---清除计时器
var interval = setInterval(run,1000); //每隔一秒执行一次run() $("").click(function(){ //点击暂停按钮 if(interval){ clearInterval(interval); interval = null; } }); $("").click(function(){ //点击继续按钮 if(interval){ clearInterval(interval); interval = null; } interval = setInterval(run,1000); }); function run(){ }