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">
  <title>JS Bin</title>
</head>
<body>
  <div id=target>
    <a id=link href="#">Link</a>
    <div id=clickbox onclick="void(0)">
      <div class=noclickbox id=box2></div>
    </div>
    <div class=noclickbox></div>
  
  <div id=log></div>
  </div>
</body>
</html>
 
#log {
  border: 1px solid black;
  margin: 5px;
  padding: 5px;
}
#clickbox {
  width: 100px;
  height: 100px;
  background-color: blue;
}
.noclickbox {
  width: 50px;
  height: 50px;
  background-color: red;
}
 
function onEvent(e) {
  document.getElementById('log').innerHTML += e.type + ": " + e.target.nodeName +
    (e.target.id ? "#" + e.target.id : "") + "<br>";
};
var target = document.getElementById('target');
target.addEventListener('touchstart', onEvent);
target.addEventListener('click', onEvent);
target.addEventListener('contextmenu', onEvent);
target.addEventListener('mousedown', onEvent);
                          
                          
Output

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

Dismiss x
public
Bin info
rbyerspro
0viewers