这样写 setInterval('alert("Hello")', 3000);

或者 这样写

setInterval(clock, 3000);
function clock()
  {
console.log('aaaa');
  

  }

但是就是不能这样写

        setInterval(clock(), 3000);

function clock()
  {
console.log('aaaa');
  

  }

小例子:

<body>
<button id="start">开始</button>
<button id="end">停止</button>
<div id="test"> </div>
<script>
window.οnlοad=function(){
var oStart=document.getElementById('start');
var oEnd=document.getElementById('end');
var testDiv=document.getElementById('test');
var num=10;
var interIndex;
oStart.οnclick=function(){
interIndex=setInterval(clock,10);
}
function clock()
  {
  console.log('test');
  num++;
   testDiv.style.left=num+'px';
  }
oEnd.οnclick=function(){
clearInterval(interIndex);
}
}
</script>
</body>