function getIndex(el){
var index = 0;
while (el = el.previousElementSibling) {
index++;
}
return index;
}
const getIndex = el => [...el.parentNode.children].indexOf(el);
function getNodeIndex(node){
return node && node.parentNode && [].indexOf.call(node.parentNode.children, node);
}
var log=document.getElementById("log");
document.body.addEventListener("mouseover",function(event){
log.innerHTML="Node index="+getNodeIndex(event.target);
})