Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <meta charset=utf-8 />
  <title>JS Bin</title>
  <style>
    ul {
      float: left;
    }
  </style>
</head>
<body>
  <ul id="first">
    <li>
      <span>1</span>
    </li>
    <li>
      <span>2</span>
    </li>
    <li>
      <span>3</span>
    </li>
  </ul>
  <ul id="second">
    <li>
      <span>1</span>
    </li>
    <li>
      <span>2</span>
    </li>
    <li>
      <span>3</span>
    </li>
  </ul>
  <script>
    var colors = [ "red", "blue", "green" ];
    
    $("#first").children().each(function (index) {
      this.style.backgroundColor = colors[index];
    });
    
    $("#second").find("span").parent().each(function (index) {
      this.style.backgroundColor = colors[index];
    });
  </script>
</body>
</html>
Output 300px

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

Dismiss x
public
Bin info
bundyopro
0viewers