Reputation:
In OpenCart when I am showing the discounts in more number quantity of product it is showing in a default way just in a single row. But I tried to change the look and made it like this
<div class="discount">
<table>
<tr>
<?php foreach ($discounts as $discount) { ?>
<td class="test">
<?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?>
</td>
<?php } ?>
</tr>
</table>
</div>
Here it is showing okay when 5 discounts in a row. But now I want to insert another row after 5th td. I want to show another 5 tds inside another tr. So can someone help me how to do this in jQuery?
Upvotes: 0
Views: 2735
Reputation: 521
easier to conclude by 5 in a row on the php
<div class="discount">
<table>
<?php for ($i = 0; $i < count($discounts); ) { ?>
<tr>
<?php for ($j = 0; $j < 5 && $i < count($discounts); $j++, $i++) { ?>
<td class="test">
information
</td>
<?php } ?>
</tr>
<?php } ?>
</table>
</div>
Upvotes: 0
Reputation: 26143
If you just want to add another tr after the last one then this will do it...
$("<tr />").insertAfter(".discount table tr:last");
It's got no cells in it, so you'd need to add them as well, which you could do like this...
$("<tr><td/><td/><td/><td/><td/></tr>").insertAfter(".discount table tr:last")
Upvotes: 2
Reputation: 3677
$(".discount table tr td:eq(4)").after("<tr><td>.....</td></tr>");
try some thing like this
if you want to insert tr
td
after 5th tr
use this
$(".discount table tr:eq(4)").after("<tr><td>.....</td></tr>");
Upvotes: 1