我希望在每个循环run.image没有出现任何帮助的情况下在表内添加一个图像将不胜感激,谢谢你
for (var i = 0; i < result.length; i++) {
doc1 = result[i];
if (doc1.PHOTO == "") {
var elem1 = document.createElement("img");
elem1.setAttribute("src", '../common/images/Icon-60.png');
elem1.setAttribute("height", "60");
elem1.setAttribute("width", "60");
var tbody = $("<tbody>").appendTo(table);
var tr = $("<tr>").appendTo(tbody);
var td = $("<td>").html(doc1.ENAME).data(doc1).appendTo(tr);
var tr2 = $("<tr>").appendTo(tbody);
var td2 = $("<td>").html(elem1).appendTo(tr2);
}
答案 0 :(得分:0)
我不确定这会解决您的问题,但请尝试:
for (var i = 0; i < result.length; i++) {
var doc1 = result[i];
if (doc1.PHOTO == "") {
var elem1 = "<img src='../common/images/Icon-60.png' height='60' width='60'/>");
table.append('<tr><td data-name='+doc1+'>'+doc1.ENAME+'</td></tr><tr><td>'+elem1+'</td></tr>');
}
}
希望这有帮助。