有没有人知道如何解决此问题或遇到类似问题?如果我写错了代码,请告诉我。谢谢。
<script type='text/javascript'>
//Getting table by id
var table = document.getElementById(str);
//Creating New Row
var row = document.createElement("tr");
//Creating New TD
var td1 = document.createElement('td');
//Creating new input.
var newInput= document.createElement('input');
newInput.setAttribute('type', 'text');
newInput.setAttribute('class', 'quantity');
//Appending newInput to TD - Return Appendchild of undefined
td1.appenChild(newInput);
//Append td to tr
row.appendChild(td1);
//Append tr to table
table.children[0].appendChild(row);
</script>
答案 0 :(得分:1)
您错过了函数名称中的d
,appenChild
应为appendChild
:
//Appending newInput to TD - Return Appendchild of undefined
td1.appendChild(newInput);