var links = document.getElementsByTagName("a");for(var i=0; i<links.length; i++) { console.log(jQuery.trim(links[i].href) + "," + jQuery.trim(links[i].innerText).replace(/(?:\r\n|\r|\n)/g, '')); }