Posted By

noah on 07/14/07


Tagged

search html DOM name utilities sanitycheck


Versions (?)

Find doubled IDs in the DOM


 / Published in: JavaScript
 

  1. var allTags = document.body.getElementsByTagName('*');
  2. var ids = {};
  3. var doubledIds = [];
  4. for (var tg = 0; tg< allTags.length; tg++) {
  5. var tag = allTags[tg];
  6. if (tag.id) {
  7. if (! ids[tag.id]) {
  8. ids[tag.id] = true;
  9. } else {
  10. doubledIds.push(tag.id);
  11. }
  12. }
  13. }
  14. alert('doubled ids: ' + doubledIds);

Report this snippet  

You need to login to post a comment.