Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<ol>
  <li>11111111</li>
  <li>22222222</li>
  <li>33333333</li>
  <li>44444444</li>
  <li>55555555</li>
  <li>66666666</li>
  <li>77777777</li>
  </ol>
</body>
</html>
 
//The querySelectorAll returns a node list based on our CSS pseudo-selector
//to reiterate, var x is not a single item, but a list of all items that meet "odd" criteria
var x = document.querySelectorAll("li:nth-child(odd)");
//for example, we can change the color of each item in the node list
for(var i = 0; i < x.length; i++){
  x[i].style.color="red"
}
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers