<!DOCTYPE html> <html> <head> <style> span, strong, p { padding: 8px; display: block; border: 1px solid #999; } </style> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> </head> <body> <div id="log"></div> <div> <p> <strong><span>click</span></strong> </p> </div> <script>$("body").click(function(event) { $("#log").html("clicked: " + event.target.nodeName); //$("#log").html("clicked: " + this.nodeName);}); </script> </body> </html>
event.target表示发生点击事件的元素;
this表示的是注册点击事件的元素。