当前位置:网站首页>动态设置img标签图片失效问题
动态设置img标签图片失效问题
2022-08-09 07:53:00 【CS打赢你】
$(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);
});
});
如果直接append标签内容,图片是不会生效的,必须在插入标签后,再对src属性进行赋值,这样才会生效。
必须加上:
$('#'+image).attr('src',data.documentPath);
边栏推荐
猜你喜欢
随机推荐
如何把无用的代码注释为 Deprecated 弃用
[STL]stack与queue
975. 奇偶跳 有序集合
car-price-deeplearning-0411
Codeforces Round #359 (Div. 2) C. Robbers' watch 暴力枚举
resourcemanager启动失败,别的节点成功
引导过程与服务控制
贪吃蛇小游戏——C语言
tianqf's problem-solving ideas
Data storage implementation of SDRAM and read and write operations on its data
yolov5 detects the number of labels in the dataset
Record a failure to upgrade the client's APP database version number
解决pycharm每次新建项目都要重新pip安装一些第三方库等问题
Unity 3D模型展示框架篇之资源打包、加载、热更(二)
【机器学习】支持向量机(SVM)代码练习
Win10桌面图标排列混乱
环形链表问题(判环、求入口点)
Invoker 2019CCPC Qinhuangdao Station I Question Simple DP
种子数据报错:liquibase.exception.ValidationFailedException: Validation Failed
Laravel文档阅读笔记-Rendering JSON(对JS变量进行赋值)