Normally I'm doing it this way:
for(i=0;i<elem.parentNode.length;i++) { if (elem.parentNode[i] == elem) //.... etc.. etc... }
You could count siblings... The childNodes list includes text and element nodes-
function whichChild(elem){ var i= 0; while((elem=elem.previousSibling)!=null) ++i; return i; }
1.4m articles
1.4m replys
5 comments
57.0k users