setTimeout
function hello(){ alert("hello"); } // Execute the method using the method name var t1 = window.setTimeout(hello,1000); var t2 = window.setTimeout("hello()",3000);//Execute method using string window.clearTimeout(t1);//Clear timer
setInterval
//Real-time refresh time unit is milliseconds setInterval('refreshQuery()',8000); /* refresh query */ function refreshQuery(){ $("#mainTable").datagrid('reload',null); }
Recommended tutorial: “JS Tutorial”
The above is the detailed content of the difference between setTimeout and setInterval in JS. For more, please pay attention to other related articles on 1024programmer.com!