You need to send the current clicked element to the function like
<div onclick="countPos(this)"></div>
Then in the function you can create an array
of the elements inside the parent then find the index.
function countPos(elem){
var nodeList = Array.prototype.slice.call( elem.parentNode.children );
var index = nodeList.indexOf( elem ) + 1;
// do your stuff with index
}