Ferris教程学习笔记:js示例3.3 累加按钮,自加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;}
 7  input{font:12px arial;cursor:pointer;padding:0 10px;}
 8 </style>
 9 </head>
10 <body>
11 <input value="2" type="button">
12 <script type="text/javascript">
13 window.onload = function(){
14    var input = document.getElementsByTagName("input")[0];
15    input.onclick = function(){
16        this.value = ++this.value;
17    };
18 };
19 </script>
20 </body>
21 </html>

 

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