The problem come in when you try using textArray.innerHTML=something. This will take the href link and add it as a string in the random-class text content. Otherwise the DOM is manipulated