Javascript: log elements with duplicated id's
// show elements with duplicated id's
var nodes = document.querySelectorAll('[id]');
var ids = {};
var totalNodes = nodes.length;
for(var i=0; i<totalNodes; i++) {
var currentId = nodes[i].id ? nodes[i].id : "undefined";
if(isNaN(ids[currentId])) {
ids[currentId] = 0;
}
ids[currentId]++;
}
for(var key in ids) {
var value = ids[key];
if (value > 1) {
console.log(value, key);
}
}