  
TA的每日心情 | 擦汗 2018-6-12 09:41 |
---|
签到天数: 273 天 [LV.8]以坛为家I
|
setTimeout(‘test()’,1000); 第一个参数要调用的函数名,第二个参数是延时的时间。时间到达以后调用test函数。
测试代码:- <html>
- <head><title>timout的作用</title>
- <script>
- function test(){
- alert('test123');
- }
- function bang(){
- var input = document.getElementsByName('input')[0];
- if (input.value == 0) {
- alert('aa');
- }else{
- setTimeout('test()',1000);
- }
- alert("abc");
- }
- </script>
- </head>
- <body>
- <input name="input" type="submit" value="5" onclick="bang();">
- </body>
- <html>
复制代码 |
|