Skip to content

Instantly share code, notes, and snippets.

@thinsoldier
Created March 6, 2015 17:51
Show Gist options
  • Save thinsoldier/9f5d9822fade6806ad6e to your computer and use it in GitHub Desktop.
Save thinsoldier/9f5d9822fade6806ad6e to your computer and use it in GitHub Desktop.
Detect duplicate id's in html document.
jq = jQuery;
var collection = {};
// change selector to * for everything use it to limit the kinds of nodes that get inspected.
jq('[name*=amenities]').each(
function(i,e){
var found = jq('[id=' + e.id + ']');
var count = found.length;
if( count > 1 ) {
collection[e.id] = {'count':count,'elements':jq.makeArray(found)};
}
}
);
console.table(collection);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment