나는 table
입니다. 그 안에는 single row for form input elements
이 있습니다. 나는 add line
이라는 이름의 button
을 넣었다. 단지 below that table
이다. 사용자가 clicks on the button add line
인 경우 add another row in that table
이됩니다. 하지만 여기에 사용자가 버튼을 클릭하면 라인이 추가 될 것이므로 add another row with increment id
이 필요합니다. 지금 내가 row_1 id is visible
을 가지고 있다고 가정 해보십시오. 사용자가 add line button
을 클릭하면 newly added row's id will be row_2
이지만 다른 행이 표시됩니다. 여기에 내가 아직 한 코드가jQuery 증가 순서가있는 테이블에 행 추가
<!DOCTYPE HTML>
<html lang="en-IN">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<script type="text/javascript" src="jquery1.7.2.js"></script>
<body>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#add-line").click(function() {
var row = jQuery('.prototype tr').clone(true);
row.find("input:text").val("");
row.appendTo('.form-fields table');
return false;
});
});
</script>
<div id="form">
<table id="form-headings">
<tr>
<td width="15%">Id</td>
<td width="16%">Name</td>
<td width="13%">Col3</td>
<td width="14%">Col4</td>
<td width="12%">Col5</td>
</tr>
</table><!--table#form-headings-->
<div id="row_1">
<div class="form-fields">
<table>
<tr>
<td><input type="text" id="form_id" size="5px"/></td>
<td><input type="text" id="form_name" size="5px"/></td>
<td><input type="text" id="form_col3" size="5px"/></td>
<td><input type="text" id="form_col4" size="5px"/></td>
<td><input type="text" id="form_col5" size="5px"/></td>
</tr>
</table>
</div><!--.form-fields-->
</div><!--#row_01-->
<input type="button" id="add-line" value="Add Line" />
</div><!--#form-->
<table class="prototype" style="display:none">
<tr>
<td><input type="text" id="form_id" size="5px"/></td>
<td><input type="text" id="form_name" size="5px"/></td>
<td><input type="text" id="form_col3" size="5px"/></td>
<td><input type="text" id="form_col4" size="5px"/></td>
<td><input type="text" id="form_col5" size="5px"/></td>
</tr>
</table><!--table.prototype-->
</body>
</html>
row_1 id는 div의 ID입니다. 그렇다면 어떻게 행을 만들 수 있습니까 – muthu