Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <script>
      function  mainDiv(){
    alert("main div is clicked");
  }
  function  subDiv(e){
    e.cancelBubble = true;
     if (e.stopPropagation) e.stopPropagation();
    alert("sub div is clicked");
  }
</script>
<div onclick="mainDiv()">
  show main div
  <div onclick="subDiv(event)">
    show sub div
  </div>
</div>
</body>
</html>
Output

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

Dismiss x
public
Bin info
dystroypro
0viewers