<body>
<div id="a"></div>
<i id='a'></i>
<i id='b'></i>
<i id='d'></i>
<i id='c'></i>
<i id='d'></i>
<script>
var children = document.body.children;
var idMap = {};
for (var i = 0; i < children.length; i++) {
if (children[i].id){
var el = document.querySelector('#'+children[i].id);
idMap[el.id] = idMap[el.id] ? idMap[el.id] + 1 : 1;
}
}
console.log(idMap);
</script>
</body>