jQuery each returning only last element, Google charts API

后端 未结 1 646
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-24 10:35

I\'ve the following code which will take an array and append to the page dynamically a QR code with the text being an element in the array.

$(document).ready(fun         


        
相关标签:
1条回答
  • 2021-01-24 11:19

    The selector where you append the image to the body is wrong. You are selecting all existing img elements, whereas you want to create a new one. Try this:

    var $img = $('<img />').attr('src', qrUrl + $.param(options)).appendTo('body');
    

    Example fiddle

    Note: $('<img />') not $('img').

    0 讨论(0)
提交回复
热议问题