Linked Questions

Popular Questions

Using array.join() in javascript

Asked by At

I am trying to make a list of every item in an array like that:

var prefetch = document.getElementById("pagetitle2");
var array_prefetch = array[1];
prefetch.innerHTML = '<li>' + array_prefetch.join('</li><li>') + '</li>';

In HTML:

<ul class="results" id='pagetitle2'></ul>

I also want array_prefetch value to be a clickable link, which means I need to add <a href=""> into every <li></li> somehow. However I don't know how to split the tag. Is there a way how to do that?

Related Questions