我有一个有几行的表,除了第一行之外,所有行都是隐藏的。我添加了一个按钮,我希望用户能够单击该按钮以单独显示表格的更多行。但是,我不能将这些行附加到表中,因为这会增加整体的行数并丢弃打印样式表。我在 Javscript 方面不是最好的,但我希望有一种方法可以使用 Javascript 或 jQuery 来单击按钮并显示下一个表格行,如果需要另一个表格行,用户可以再次单击“添加更多”按钮显示下一个表格行。我已经在 HTML 中列出了最大表格行数。
http://jsfiddle.net/jasonniebauer/j5agK/2/
HTML
<table id="processing_table">
<tr>
<td class="table_label">
Quantity
</td>
<td class="table_qty">
<input type="text" id="qty1" placeholder="Qty"/>
</td>
<td class="table_label">
Description <span id="processing_small_header">(Vendor, Model/Name, and Version)</span>
</td>
<td class="table_description">
<input type="text" id="description1" placeholder="Description"/>
</td>
<td class="table_label">
Connection
</td>
<td class="table_connection">
<input type="text" id="connection1" placeholder="Type"/>
</td>
<td class="table_label">
Template
</td>
<td class="table_template">
<input type="text" id="template1" placeholder="Template"/>
</td>
</tr>
<tr>
<td class="table_label">
Quantity
</td>
<td class="table_qty">
<input type="text" id="qty2" name="more_fields" placeholder="Qty"/>
</td>
<td class="table_label">
Description <span id="processing_small_header">(Vendor, Model/Name, and Version)</span>
</td>
<td class="table_description">
<input type="text" id="description2" name="more_fields" placeholder="Description"/>
</td>
<td class="table_label">
Connection
</td>
<td class="table_connection">
<input type="text" id="connection2" name="more_fields" placeholder="Type"/>
</td>
<td class="table_label">
Template
</td>
<td class="table_template">
<input type="text" id="template2" name="more_fields" placeholder="Template"/>
</td>
</tr>
<tr>
<td class="table_label">
Quantity
</td>
<td class="table_qty">
<input type="text" id="qty3" placeholder="Qty"/>
</td>
<td class="table_label">
Description <span id="processing_small_header">(Vendor, Model/Name, and Version)</span>
</td>
<td class="table_description">
<input type="text" id="description3" placeholder="Description"/>
</td>
<td class="table_label">
Connection
</td>
<td class="table_connection">
<input type="text" id="connection3" placeholder="Type"/>
</td>
<td class="table_label">
Template
</td>
<td class="table_template">
<input type="text" id="template3" placeholder="Template"/>
</td>
</tr>
<tr>
<td class="table_label">
Quantity
</td>
<td class="table_qty">
<input type="text" id="qty4" placeholder="Qty"/>
</td>
<td class="table_label">
Description <span id="processing_small_header">(Vendor, Model/Name, and Version)</span>
</td>
<td class="table_description">
<input type="text" id="description4" placeholder="Description"/>
</td>
<td class="table_label">
Connection
</td>
<td class="table_connection">
<input type="text" id="connection4" placeholder="Type"/>
</td>
<td class="table_label">
Template
</td>
<td class="table_template"/>
<input type="text" id="template4" placeholder="Template"/>
</td>
</tr>
<tr>
<td class="table_label">
Quantity
</td>
<td class="table_qty">
<input type="text" id="qty5" placeholder="Qty"/>
</td>
<td class="table_label">
Description <span id="processing_small_header">(Vendor, Model/Name, and Version)</span>
</td>
<td class="table_description">
<input type="text" id="description5" placeholder="Description"/>
</td>
<td class="table_label">
Connection
</td>
<td class="table_connection">
<input type="text" id="connection5" placeholder="Type"/>
</td>
<td class="table_label">
Template
</td>
<td class="table_template">
<input type="text" id="template5" placeholder="Template"/>
</td>
</tr>
<tr>
<td class="table_label">
Quantity
</td>
<td class="table_qty">
<input type="text" id="qty6" placeholder="Qty"/>
</td>
<td class="table_label">
Description <span id="processing_small_header">(Vendor, Model/Name, and Version)</span>
</td>
<td class="table_description">
<input type="text" id="description6" placeholder="Description"/>
</td>
<td class="table_label">
Connection
</td>
<td class="table_connection">
<input type="text" id="connection6" placeholder="Type"/>
</td>
<td class="table_label">
Template
</td>
<td class="table_template">
<input type="text" id="template6" placeholder="Template"/>
</td>
</tr>
</table>
Javascript
$('#add_more').click(function() {
document.getElementById('#processing_table tr').style.display = "block";
});