Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
  
  #parent{
    width: 300px;
    height: 300px;
    background: #121212;
  }
  
  #child{
    width: 100px;
    height: 100px;
    background: #212121;
  }
</style>
</head>
<body>
  <div id="parent">
    <div id="child"></div>
  </div>
</body>
</html>
 
$(document).click(function(event){
    console.log("parent event "+event);
    alert("In Parent Handler");
   event.stopImmediatePropagation();
});
$("#child").click(function(event){
  console.log("event ", event);
   alert("In Child Handler");
    //return false;
  event.stopImmediatePropagation();
  //event.stopPropagation();
  //return false;
});
$("#child").click(function(event){
  console.log("child 2 event ", event);
    alert("In Child 2 Handler");
  event.stopImmediatePropagation();
    //return false;
});
$(document).click(function(event){
    console.log("parent event 2"+event);
    alert("In Parent Handler2");
  event.stopPropagation();
});
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers