我让它在一页上工作-但是当我提取代码时它不起作用。
我已将代码最小化以供您查看:
<table class="lightlines">
<tr>
<td valign="top">Title:</td>
<td><input type="text" value="" name="titleText" id="titleText">
<p id="cloneMe">
<table class="lightlines">
<tr>
<td>P/N: </td>
<td><input type="text" value="" name="pnText" id="pnText"></td>
<td>Description: </td>
<td><input type="text" value="" name="pnDescText" id="pnDescText"></td>
</tr>
</table>
</p>
<p id="theClones">
</p>
</td>
</tr>
<tr>
<td colspan="6" align="right"><input type="button" name="addPNRow" id="addPNRow" value="add row" /><input type="button" name="saveTitleText" id="saveTitleText" value="save" /></td>
</tr>
</table>
<script>
$(function(){
var cloneCount = 0;
$('#addPNRow').click(function(){
var cl = $('#cloneMe').clone().attr({
id: 'cloneMe_' + cloneCount
}).find('[id^="pnText"]').attr({
value: '',
id: 'pnText_' + cloneCount
}).end().find('[id^="pnDescText"]').attr({
value: '',
id: 'pnDescText_' + cloneCount
}).end().appendTo('#theClones');
cloneCount++;
});
});
</script>
这是一个小提琴:http: //jsfiddle.net/Mh4f8/11/