Skip to content

Instantly share code, notes, and snippets.

@iamandrewluca
Last active April 6, 2020 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamandrewluca/8f52edfee4891732183a257be8c8cb51 to your computer and use it in GitHub Desktop.
Save iamandrewluca/8f52edfee4891732183a257be8c8cb51 to your computer and use it in GitHub Desktop.
Find and mark elements with on page which have duplicate IDs
javascript: void ((function() {
const ids = document.querySelectorAll('[id]');
Array.from(ids).forEach(el => {
const id = document.querySelectorAll(`[id="${el.id}"]`);
if (id.length > 1 && id[0] === el) {
console.log('Duplicate id ' + el.id);
Array.from(id).forEach(fel => {
fel.style.outline = '5px solid red';
});
alert('duplicate found');
}
});
})());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment