Skip to content

Instantly share code, notes, and snippets.

@seutje
Created May 9, 2011 15:03
Show Gist options
  • Save seutje/962685 to your computer and use it in GitHub Desktop.
Save seutje/962685 to your computer and use it in GitHub Desktop.
Look for duplicate IDs and report them in the console
(function(a){var b=[],c="";a("[id]").each(function(c,d){if(a("[id="+this.id+"]").length>1){b.push(this.id)}});if(b.length){c="Druplicate IDs: "+b.join(", ");window.console&&window.console.log?window.console.log(c):window.alert(c)}})(jQuery)
(function($) {
var duplicates = [],
msg = '';
$('[id]').each(function(i, el) {
if ($('[id=' + this.id + ']').length > 1) {duplicates.push(this.id);}
});
if (duplicates.length) {
msg = 'Druplicate IDs: ' + duplicates.join(', ');
window.console && window.console.log ? window.console.log(msg) : window.alert(msg);
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment