Created
April 6, 2015 23:30
-
-
Save chainat/825ac2a9da50989f3f55 to your computer and use it in GitHub Desktop.
Check duplicate html element ID on the page
This file contains hidden or 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
(function findDuplicateIds(){ | |
var ids = {}; | |
var all = document.all || document.getElementsByTagName("*"); | |
for(var i=0, l=all.length; i<l; i++){ | |
var id = all[i].id; | |
if(id){ | |
if(ids[id]){ | |
console.log("Duplicate id: #" + id); | |
} else { | |
ids[id] = 1; | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment