Domanda

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>')
È stato utile?

Soluzione

Try this:

$.getJSON('/test-url/123').done (data) ->
  $.each data, (index, value) ->
    $('.col ul').append('<li><img src=' + value['m'] + '><li>')
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top