Reputation: 1272
I'm trying to list v.name
in <li>...</li>
using this working function (it's currently listing the last name
value and putting it in a single <li>
).
$.getJSON(projectMedias, function (data) {
$.each(data.medias, function (i, v) {
var name = v.name;
$('ul').html('<li>' + name + '</li>');
})
});
Any help to get it to cycle through, and list all name
values?
Upvotes: 0
Views: 21
Reputation: 25352
.html() will replace previous content
Use .append() instead.
Convert this
$('ul').html('<li>' + name + '</li>');
to this
$('ul').append('<li>' + name + '</li>');
Upvotes: 1