var a = ''; [].forEach.call(document.querySelectorAll('a[class=black]'), function(item) { a = a + item.href; });