1.
$(function(){
setInterval (showTime, 2000);
function showTime(){
var today = new Date();
alert("The time is: " + today.toString ());
}
})
2.
$(function(){
$.extend({
showTime:function(){
alert("The time is: " + today.toString ());
}
setInterval($.showTime,3000);
})
})
3.清除定時器
//把定時器賦值給一個變量 var int=setInterval(function(){}, timer); //清除定時器 clearInterval(int);