Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<base href="http://docs.jquery.com" />
<script src="http://code.jquery.com/jquery-1.3.js"></script>
 
</head>
<body>
  <div class='parent' style='height:100px;border:solid 1px red'>
Im the Parent
    <div class='child' style='margin-left:20px;color:black;'> green</div>
    <div class='child' style='margin-left:20px;color:black;'> red</div>
    <div class='child' style='margin-left:20px;color:black;'> yellow</div>
    <div class='child' style='margin-left:20px;color:black;'> im the child4</div>
  
  <div>
<script>
 
  $(".child").click (function () {
  
  $(this).parents(".parent").css('color',$(this).html());
  
  
  });
  
</script>
</body>
</html>
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers