user2931706
user2931706

Reputation:

jQuery html not working as expected

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>')

Upvotes: 0

Views: 27

Answers (1)

Leonardo Delfino
Leonardo Delfino

Reputation: 1498

Try this:

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

Upvotes: 1

Related Questions