 <p>This should work:</p> <pre><code>function removeDups() { var container = document.getElementById("success"); var a = container.getElementsByTagName("a"); var hrefs = {}; for (var i = 0; i &lt; a.length; i++) { if (a[i].href in hrefs) { a[i].parentNode.removeChild(a[i]); } else { hrefs[a[i].href] = 1; } } } </code></pre> <p><a href="http://jsfiddle.net/fDPsH/" rel="nofollow">http://jsfiddle.net/fDPsH/</a></p>