Question

I'm trying to insert new li with img element inside ul based on array, so i'm doing this, but just first item in array is being inserted

$.getJSON('/test-url/123').done (data) ->
  $.each data, (index, value) ->
    $('.col ul').html('<li><img src=' + value['m'] + '><li>')
Was it helpful?

Solution

Try this:

$.getJSON('/test-url/123').done (data) ->
  $.each data, (index, value) ->
    $('.col ul').append('<li><img src=' + value['m'] + '><li>')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top