[英]How do I add a button to a td using js and set multiple attr?
My code is this, but attr delete botton, not work 我的代码是这样,但是attr delete botton,不起作用
var newList = snapshot.val();
var tableList = document.getElementById('mytable');
var rowIndex = 1;
var row = tableList.insertRow(rowIndex);
var cellName = row.insertCell(0);
var cellBottonDelete = row.insertCell(1);
cellName.appendChild(document.createTextNode(newList.name));
cellBottonDelete.appendChild(document.createElement("input", { type: "button", value:"Delete"}));
rowIndex = rowIndex + 1;
input is created but attr not. 输入已创建,但属性未创建。 Any idea? 任何想法?
It's the solution 这是解决方案
var newList = snapshot.val();
var tableList = document.getElementById('mytable');
var rowIndex = 1;
var row = tableList.insertRow(rowIndex);
var cellName = row.insertCell(0);
var cellBottonDelete = row.insertCell(1);
var itd = document.createElement('input');
itd.setAttribute("type","button");
itd.setAttribute("value","Delete");
cellName.appendChild(document.createTextNode(newList.name));
cellBottonDelete.appendChild(itd);
rowIndex = rowIndex + 1;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.