js脚本中的this

 1 <html>
 2 <head>
 3     <script type="text/javascript" src="jquery.min.js"></script>
 4 </head>
 5 <body>
 6     <script type="text/javascript">
 7         $(document).ready(function () {
 8             $("button").click(function () {
 9                 alert(this);//2,Html Element
10                 alert($(this));//3,jqueyr object
11                 test(this);//4,可以传递
12                 test($(this));//5,可以传递
13             });
14         });
15         function test(v) {
16             alert(v.id);
17         }
18         test(this); // 1,Window
19     </script>
20     <button type="button" id="btn">Click me</button>
21 </body>
22 </html>

 

posted @ 2013-12-16 17:03  幸运的程序员  阅读(110)  评论(0)    收藏  举报