Jacklovely

导航

 
 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4     <title>延时器</title>
 5     <style type="text/css">
 6         input
 7         {
 8             width: 500px;
 9         }
10     </style>
11     <script type="text/javascript">
12         onload = function () {
13             var timeoutId;
14             //在第一个框里输入内容,一秒后在第二个框里显示
15             text1.onkeyup = function () {
16                 clearTimeout(timeoutId);
17                 timeoutId = setTimeout(function () {
18                     text2.value = text1.value;
19                 }, 1000);
20 
21             }
22 
23         }
24     </script>
25 </head>
26 <body>
27     <input type="text" name="name" value=" " id="text1" /><br /><br /><br />
28     <input type="text" name="name" value=" " id="text2" />
29 </body>
30 </html>

 

posted on 2016-04-07 10:22  Jacklovely  阅读(268)  评论(0编辑  收藏  举报