在下面的代码中,我如何在作业详细信息标题下方显示的添加和删除按钮下方动态生成文本框。
HTML:
<table border="0" cellspacing="2">
<tr>
<td style="width:200px;" align="right">Name
<td>
<input type="text" id="Job Name" value="" />
</td>
</td>
</tr>
<tr>
<td align="right">Versions</td>
<td>
<select id="version" style="width:350px;">
<option value="">SELECT</option>
</select>
</td>
</tr>
<tr>
<td align="right">Test Scripts</td>
<td>
<select id="testscripts" style="width:350px;"></select>
</td>
</tr>
<tr>
<td align="right">datas</td>
<td>
<input type="button" id="add" value="Add" onclick="AddTables();" />
<input type="button" id="del" value="Del" />
</td>
</tr>
<tr>
<td style="height:3px" colspan="2"></td>
</tr>
<tr style="background-color: #383838">
<td></td>
<td>
<input type="button" id="adde" value="New" onclick="clearData();" />
<input type="button" id="edit" value="Save" onclick="saveToDB();"
/>
<input type="button" id="delete" value="Delete" onclick="deleteData();"
/>
</td>
</tr>
<tr>
<td colspan="2">
<h2>Job Details</h2>
<div id="navcont" style="width: 880px; height: 5px; margin-left: 0px; margin-top: 0px; list-style: none; float: left;background-color: #383838"></div>
</td>
</tr>
<tr>
<td colspan="2">
<!-- TODO:change this as div, create table inside helper script-->
<div id="jobsTable"></div>
</div>
</div>
</td>
</tr>
</table>
查询:
$('#add').click(function () {
var table = $(this).closest('table');
if (table.find('input:text').length < 7) {
table.append('<tr><td style="width:200px;" align="right">First Name <td> <input type="text" id="current Name" value="" /> </td><td style="width:200px;" align="right">Last Name <td> <input type="text" id="current Name" value="" /> </td></tr>');
}
});
$('#del').click(function () {
var table = $(this).closest('table');
if (table.find('input:text').length > 1) {
table.find('input:text').last().closest('tr').remove();
}
});