JSFiddle - React, Tailwind, and code Playground

HTML

<div id="a"></div>
<div id="a"></div>
<div id="b"></div>

JavaScript

var re = /id="(.*?)"/g;
var nl = /\n\r?/g;
var text = document.documentElement.innerHTML;
var match;
var ids = {};
var index = 0;
while (match = re.exec(text)) {
    index = text.indexOf(match[0], index + 1);
    if (match[1] in ids) {
        console.log("duplicate match at line " +
          text.substring(0, index).match(nl).length);
    } else {
        ids[match[1]] = null;
    }
}