JS table generator with buttons

前端 未结 3 1370
自闭症患者
自闭症患者 2021-01-16 02:30

I found this answer on the website and used it as a base for my own code.

I was trying to get the buttons to render within the table but it just came up as text and n

3条回答
  •  粉色の甜心
    2021-01-16 02:59

    createTextNode() creates a text node, as the name says. If you have markup in it, it will be shown literally.

    You should have created a button node, and set its text to the variables like this example below.

        for (var i = 0; i <10; i++) {
          var cell = document.createElement("td");
          var btn = document.createElement("button");
          btn.innerText = j + "-" + i;
          cell.appendChild(btn);
          row.appendChild(cell);
        }
    

提交回复
热议问题