I recommend that you use jQuery for this, as it makes the process much easier. Here are some examples using jQuery:
$("div#id").append('<a href="' + url + '">' + text + '</a>');
If you need a list though, as in a <ul>
, you can do this:
$("div#id").append('<ul>');
var ul = $("div#id > ul");
ul.append('<li><a href="' + url + '">' + text + '</a></li>');