Ferris教程学习笔记:js示例3.5 页面加载后累加,自加1

 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"><head>
 3 <meta http-equiv="Content-Type" content="text/html; charset=gbk">
 4 <title>页面加载后累加,自加1</title>
 5 <style type="text/css">
 6 body{text-align:center;font:700 30px/1.5 arial;}
 7 </style>
 8 </head>
 9 <body>
10 5
11 <script type="text/javascript">
12  window.onload = function(){
13    var i = 1;
14    var d = document.body;
15    setInterval(function(){
16      d.innerHTML = ++i;
17    },1000);
18  }
19 </script>
20 </body>
21 </html>

 

posted @ 2013-12-13 16:41  kaka100  阅读(235)  评论(0编辑  收藏  举报