Skip to content

Instantly share code, notes, and snippets.

@jasonmerino
Last active August 29, 2015 14:02
Show Gist options
  • Save jasonmerino/f779d27fe0357f7c9af8 to your computer and use it in GitHub Desktop.
Save jasonmerino/f779d27fe0357f7c9af8 to your computer and use it in GitHub Desktop.
A bookmarklet to detect multiple ID's on a page
javascript:(function(){
var nodes = document.querySelectorAll('*'),
ids = [],
duplicates = [];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (node.id !== '') {
if (ids.indexOf(node.id) === -1) {
ids.push(node.id);
} else {
duplicates.push(node.id);
}
}
}
if (duplicates.length > 0) {
alert('Duplicate ID\'s found: \n\n#' + duplicates.join('\n#'));
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment