how to add image dynamically jquery -


i used following code dynamically create img, div created , works fine. input text problem img control created img not shown can't find problem please.

$.each(data.user, function (i,data) {      $("<div>"+data.id+"  </div>").attr('id',data.id).appendto('#page_14_14');     $('#'+data.id).css({"border-color": "#c1e0ff",                          "border-weight":"1px",                         "margin-top":"10px",                                             "border-style":"solid"});      var ctrl = $('<input/>').attr({ type: 'text', name:'text', value:data.email , id:data.email, disabled:true }).addclass("text");     $(ctrl).appendto("#"+data.id);      $('#'+data.email).css({"border-color": "#c1e0ff",                             "width":"50px",                            "margin-top":"10px",                                                "border-style":"solid"});      var img = $('<img/>').attr({ classname:"inline" , src:"/www/images/arrow.png" }).addclass("img");      $(img).appendto("#"+data.id);         });    

i used following 2 methods img had same problem

 var img = $('<img/>', {"class" :"inline", src:"/www/images/arrow.png"     });    var img = $('<img class="inline" src="/www/images/bg.png" width="50px" height="50px"  />'); 

just declare var img element string.

var img = '<img class="inline" src="/www/images/arrow.png" width="50" height="50" />'; 

then prepend div.

$('#' + data.id).prepend(img); 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -