抱歉问个新手问题:我想创建一个带有输入字段的表格,如果需要,用户可以添加新字段。但是我无法弄清楚如何在已经存在另一个输入字段的单元格内添加另一个输入字段。
我的代码是:
我的代码是:
var par=obj.parentNode;
while(par.nodeName.toLowerCase()!='tr')
{ par=par.parentNode; }
// this gives me the index of the row.. works fine.
cell1=document.getElementById('avz_tabelle').rows[par.rowIndex].cells;
// this puts the content of the cells into the array "cell1"
var feld = cell1[1].createElement("input");
feld.setAttribute("name","avz_keywords" + avz_array + "[]");
feld.setAttribute("onblur","");
feld.setAttribute("type","text");
feld.setAttribute("size","30");
// Now I create a input element
// And now comes the problem:
cell1[1].appendChild(feld); // --> doesn't work
有人能给我提些建议吗? 我想尝试不使用表格的方式来工作,理论上这应该可以适用于我的方法。但那样并不能令我满意 :/
element.createElement()
是有效的吗?我认为createElement()
只是document
的一个方法。 - Michael Berkowski