Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
</head>
<body id="bodyId">
  
    <div id="divId">
        <button id="btnId">按我</button>            
    </div>
    <span id="console"></span>
<script type="text/javascript">
      function handler(event) {
          let target = event.target;
          document.getElementById('console').innerHTML += 
             `<br><b>this.id:</b> ${this.id}, <b>target.id:</b> ${target.id}`;
          event.stopPropagation();
      }
  
      document.getElementById('bodyId').onclick = handler;
      document.getElementById('divId').onclick = handler;
      document.getElementById('btnId').onclick = handler;
</script>  
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
JustinSDKpro
0viewers