for (const el of document.querySelectorAll("[id]")) { el.classList.add("haspara") const pilcrow = document.createElement("a"); pilcrow.className = "pilcrow" pilcrow.href = "#" + el.id; pilcrow.innerHTML = "¶" el.prepend(pilcrow) } console.log(hasId);