show image inside table with innerhtml

Solutions on MaxInterview for show image inside table with innerhtml by the best coders in the world

showing results for - "show image inside table with innerhtml"
Lennard
25 Jan 2020
1var array = cvpls();
2var table = ``;
3for (var i = 0; i < array.length; i++) {
4  table += `<tr>`;
5  for (var j = 0; j < array[i].length; j++) {
6    if (i === 1 && j === 2) {
7      table += `<td><img src='http://imgh.us/statik.gif' style ='width:50px;height:50px'></td>`;
8    } else {
9      table += `<td>${array[i][j]}</td>`;
10    }
11  }
12  table += `</tr>`;
13  document.getElementById("Invtable").innerHTML = table;
14}
15
16function cvpls() {
17  return array = [
18    [4, 5, 6, 9, 2],
19    ['img', 'img', 'img', 'img', 'img'],
20    ['d', 'b', 'g', 'i', 'o']
21  ];
22}