IE下cloneNode(true)一个TR取其.cells[index]报 'cells.[index].firstChild'为空或不是对象
下列js代码,报“'cells.4.firstChild'为空或不是对象”:
var templateRow = copiedTable.firstChild.lastChild;var newRow = templateRow.cloneNode(true);newRow.style.display = "block";var refRow = copiedTable.firstChild.firstChild.nextSibling //insertBefore()的参照行///alert(newRow.cells[4]) ////为“undefined”newRow.cells[4].firstChild.value = curSrcRow.cells[4].firstChild.nodeValue; ///set curSrcRow's values to newRowcopyPloValues(newRow, curSrcRow);///插入新行if(refRow) { copiedTable.firstChild.insertBefore(newRow, refRow);} else { copiedTable.firstChild.appendChild(newRow);}
var templateRow = copiedTable.firstChild.lastChild;var newRow = templateRow.cloneNode(true);newRow.style.display = "block";var refRow = copiedTable.firstChild.firstChild.nextSibling //insertBefore()的参照行 ///set curSrcRow's values to newRowcopyPloValues(newRow, curSrcRow);///插入新行if(refRow) { copiedTable.firstChild.insertBefore(newRow, refRow);} else { copiedTable.firstChild.appendChild(newRow);}//alert(newRow.cells[4] + ' ' + newRow.cells[4].nodeName); ////为“[object] TD”newRow.cells[4].firstChild.value = curSrcRow.cells[4].firstChild.nodeValue;