【发布时间】:2011-10-09 17:15:49
【问题描述】:
我正在设置一个表单,它将动态创建一个文本字段并将其附加到表格中。文本字段的名称是一个数组,因此它包含括号。下面的代码不附加输入字段,而是返回 [object HTMLInputElement]。我假设这是因为括号?有没有办法做到这一点?
//HTML
<table id="notesplus" cellpadding="0" cellspacing="0">
<thead></thead>
<tbody></tbody>
</table>
//JQUERY
$(document).ready(function() {
$('input[id=addIt]').live('click', function() {
addPlus();
});
});
function addPlus() {
var item = document.createElement("textarea");
item.setAttribute("name", "section[0][aplus]"+mycount+"[notes]");
var sRow1 = $('<tr>').appendTo('table#notesplus tbody');
var sCell1 = $('<td>').html(item).appendTo(sRow1);
}
【问题讨论】: