我正在尝试使用 jQuery 在表格内动态创建复选框、按钮和 2 个输入框。下面是我的 jQuery 代码,它创建了元素但没有正确创建列。我错过了什么?
var contentTblOpen = "<table border='4'>";
var contentTblClose = "</table>";
var contentTrOpen = "<tr>";
var contentTrClose = "</tr>";
var contentTdOpen = "<td>";
var contentTdClose = "</td>";
$("#Quote" + id).after(
contentTblOpen
).append(
contentTrOpen
).append(
contentTdOpen
).append(
$(document.createElement("input")).attr({
id: 'RL_' + rLCount + '__Delete'
, name: 'RL[' + rLCount + '].Delete'
, type: 'checkbox'
, checked: false
})
.click(function (event) {
var cbox = $(this)[0];
alert(cbox.value);
})
).append(
$(document.createElement("input")).attr({
id: 'Line' + rLCount
, name: 'Line' + rLCount
, value: 'Line' + rLCount
, class: 'ClsrLButton'
, type: 'button'
})
).append(
contentTdClose + contentTdOpen
).append(
$(document.createElement("input")).attr({
id: 'RL_' + rLCount + '__TextLine'
, name: 'RL[' + rLCount + '].TextLine'
, value: 'RL_' + rLCount + '__TextLine'
, type: 'input'
})
).append(
contentTdClose + contentTdOpen
).append(
$(document.createElement("input")).attr({
id: 'RL_' + rLCount + '__Amount'
, name: 'RL[' + rLCount + '].Amount'
, value: 'RL[' + rLCount + '].Amount'
, type: 'input'
}).append(
contentTdClose + contentTrClose + contentTblClose
)
);