【发布时间】:2012-07-17 20:06:57
【问题描述】:
我想在更改事件中向我的表中添加一个新行。这是我目前所拥有的:
$('#CourseID').change(function() {
$('#CourseListTable > tr > td:last').append('<td>...</td>');
});
这是我的桌子:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<table id="CourseListTable">
<tr>
<th>Course ID</th>
<th>Course Section</th>
<th>Level</th>
</tr>
<tr>
<td><select name="CourseID" id="CourseID"></select></td>
<td><select name="CourseSection" id="CourseSection"></select></td>
<td><select name="Level" id="Level"></select></td>
</tr>
</table>
我无法让它工作。我在这里遗漏了一些东西,谁能告诉我我的错误在哪里?
提前致谢。
【问题讨论】:
-
如果您将
thead和tbody部分添加到您的表格中,您可以将新行附加到tbody...另外,我刚刚意识到您正在附加一个单元格。你想追加一个单元格还是一行?
标签: javascript jquery html-table