click冒泡到body

 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     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
 5     <title>test03</title>
 6 </head>
 7 <body>
 8     <input type="button" id="myBtn" value="点击" />
 9     <script type="text/javascript" src="test03.js"></script>
10 </body>
11 </html>
1 document.body.onclick = function(event) {
2     console.log(event.currentTarget === document.body);//true
3     console.log(this === document.body);//true
4     console.log(event.target === document.getElementById("myBtn"));//true
5 };
posted @ 2012-05-25 21:46  小猩猩君  阅读(221)  评论(0编辑  收藏  举报