Dynamic picture setting img tag failures

 $(document).ready(function(){
var list = [[${documents}]];
    $.each(list,function(i,data){
      var tr = $("#tbody");
      var image = "image"+i;
      tr.append('<tr>\n'
          + '                  <td class="table-td-label" style="width: 10%">催收附件:</td>\n'
          + '                  <td class="table-td-value" colspan="3">\n'
          + '                    <img id="'+image+'" th:src='+data.documentPath+' id="picker" style="width:100%"/>\n'
          + '                  </td>\n'
          + '                  <td></td>\n'
          + '                </tr>');

      $('#'+image).attr('src',data.documentPath);
    });
  });

If the direct append the label content, the picture is not in effect, you must insert the tag, and then the src attribute assignment, so to take effect.

It must be added:

               $('#'+image).attr('src',data.documentPath); 

Guess you like

Origin blog.csdn.net/weixin_42533856/article/details/90033061