抱歉,新手问题:我想创建一个包含输入字段的表,如果需要,可以在其中添加新字段。但我不知道如何在已经存在另一个输入字段的单元格内添加另一个输入字段。
我的代码是:
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
有人给我建议吗?
我想到了在没有桌子的情况下工作的想法,理论上这适合我的方式。但这并不令人满意:/
如果您查看调试控制台,您应该会看到类似的内容
TypeError: Object #<HTMLDivElement> has no method 'createElement'
而不是从创建元素cell1[1]
, use document.createElement()
var feld = document.createElement("input");
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)