Created
February 19, 2016 21:45
-
-
Save alexcarpenter/a5ae74ca54f92fbd77c0 to your computer and use it in GitHub Desktop.
Console log ID duplicates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]++; | |
} | |
console.log(ids); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment