无法在 'Node' 上执行 'appendChild':参数 1 不是类型 'Node' 将 tr 附加到 table 时出错
Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node' error on append tr to a table
我有以下代码:
var counter = 3;
function AddAddressRow() {
var newRow = jQuery('<tr><td><div>' +
'<select class="dropdown-wrap k-rtl " id="ddlPrefix' +
counter +
'_1" style="width: 100px;">' +
'<option value="option1" selected="selected">Option 1</option>'+
'<option value="option2">Option 2</option>' +
'</select> <br /><br/></div></td><td><div>' +
'<select class="dropdown-wrap k-rtl " id="ddlPrefix' +
counter +
'_2" style="width: 100px;">' +
'<option value="option1" selected="selected">Option 1</option>' +
'<option value="option2">Option 2</option>' <
+'/select><br /></div></td><td><input style="width: 100px;"
id="txtAddress' + counter+'"/><br/><br/></td></tr>');
counter++;
$("table#AddressTable").append(newRow);
}
点击下方按钮
<button onclick="AddAddressRow();">+</button>
我发现了类型错误:
Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'
newRow 未返回 tr 节点。
检查 fiddle here
或者尝试这样的事情:
var tr_ele = document.createElement('tr');
tr_ele.innerHTML = '>html here..<';
$("table#AddressTable").append(tr_ele);
我有以下代码:
var counter = 3;
function AddAddressRow() {
var newRow = jQuery('<tr><td><div>' +
'<select class="dropdown-wrap k-rtl " id="ddlPrefix' +
counter +
'_1" style="width: 100px;">' +
'<option value="option1" selected="selected">Option 1</option>'+
'<option value="option2">Option 2</option>' +
'</select> <br /><br/></div></td><td><div>' +
'<select class="dropdown-wrap k-rtl " id="ddlPrefix' +
counter +
'_2" style="width: 100px;">' +
'<option value="option1" selected="selected">Option 1</option>' +
'<option value="option2">Option 2</option>' <
+'/select><br /></div></td><td><input style="width: 100px;"
id="txtAddress' + counter+'"/><br/><br/></td></tr>');
counter++;
$("table#AddressTable").append(newRow);
}
点击下方按钮
<button onclick="AddAddressRow();">+</button>
我发现了类型错误:
Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'
newRow 未返回 tr 节点。 检查 fiddle here
或者尝试这样的事情:
var tr_ele = document.createElement('tr');
tr_ele.innerHTML = '>html here..<';
$("table#AddressTable").append(tr_ele);