Reputation: 687
The result of this code does not display as a link rather it displays the HTML. How do I fix this?
for(t = 0; t < jobs.length; ++t) {
$('.space').val('<a href="http://localhost:53112/category/c?id=' + jobs[t].Id + '">' + jobs[t].Occupation + ' ' + jobs[t].Years + '</a>');
}
Upvotes: 0
Views: 32
Reputation: 4277
You should use jQuery.append(), if you are adding multiple links. jQuery.html() will keep overwriting the previous link.
for(var t = 0; t < jobs.length; ++t) {
var href = 'http://localhost:53112/category/c?id=' + jobs[t].Id;
var text = jobs[t].Occupation + ' ' + jobs[t].Years;
$('.space').append($('<a/>').attr('href', href).text(text));
}
Upvotes: 2