Skip to content

Instantly share code, notes, and snippets.

@joshski
Created March 2, 2010 18:07
Show Gist options
  • Save joshski/319735 to your computer and use it in GitHub Desktop.
Save joshski/319735 to your computer and use it in GitHub Desktop.
Find duplicate element ids with jquery
var idCounts = {};
$("*").each(function() {
if (this.id != '')
idCounts[this.id] = (idCounts[this.id] || 0) + 1;
});
for (var i in idCounts) {
if (idCounts[i] > 1)
console.log(i + "=" + idCounts[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment