Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div id="a" class="level">
     Level 1 <a href="#" class="click-me">Click Me (A)</a>
    <div id="b" class="level">
      Level 2 <a href="#" class="click-me">Click Me (B)</a>
      <div id="c" class="level">
        Level 3 <a href="#" class="click-me">Click Me (C)</a>
      </div>
    </div>
  </div>
  
</body>
</html>
<style>
  .level{
    margin-left:50px;
  }
</style>
 
$(function (){
  
  $("#a").delegate(".click-me:first-child", "click", function(evt){ 
    evt.preventDefault(); 
    console.log("a was clicked"); 
  });
  
  $("#b").delegate(".click-me:first-child", "click", function(evt){ 
    evt.preventDefault(); 
    console.log("b was clicked"); 
  });
  
  $("#c").delegate(".click-me:first-child", "click", function(evt){ 
    evt.preventDefault(); 
    console.log("c was clicked"); 
  });
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers