title: Get child node index
body: <p>In straight up javascript (i.e., no extensions such as jQuery, etc.), is there a way to determine a child node's index inside of its parent node without iterating over and comparing all children nodes?</p>
  
  <p>E.g.,</p>
  
  <pre><code>var child = document.getElementById('my_element');
  var parent = child.parentNode;
  var childNodes = parent.childNodes;
  var count = childNodes.length;
  var child_index;
  for (var i = 0; i &lt; count; ++i) {
    if (child === childNodes[i]) {
      child_index = i;
      break;
    }
  }
  </code></pre>
  
  <p>Is there a better way to determine the child's index?</p>