Last active
August 29, 2015 14:02
-
-
Save ryanguill/36af48201e6d68dbbbe3 to your computer and use it in GitHub Desktop.
Small script that you can run in the console to see if you have more than one element with the same ID.
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 allElements = document.getElementsByTagName("*"), allIds = {}, dupIDs = []; | |
for (var i = 0, n = allElements.length; i < n; ++i) { | |
var el = allElements[i]; | |
if (el.id) { | |
if (allIds[el.id] !== undefined) dupIDs.push(el.id); | |
allIds[el.id] = el.name || el.id; | |
} | |
} | |
if (dupIDs.length) { console.error("Duplicate ID's:", dupIDs);} else { console.log("No Duplicates Detected"); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment