Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <a href="#!">Click to highlight every other veggie.</a>
  <ul>
    <li>Apple</li>
    <li>Grape</li>
    <li>Carrot</li>
    <li>Lettuce</li>
    <li>Broccoli</li>
  </ul>
</body>
</html>
 
ul{
list-style-type:none;
}
.highlight{
  background-color: #FAF2C8;
}
 
$('a').on('click',function(){
 
  $('ul li:nth-child(2)')
    .nextAll(':even')
    .addClass('highlight');
  
});
Output

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

Dismiss x