Beginner Beginner - 2 months ago 10
jQuery Question

Jquery adjust table to add tds into one row?

I have a table which looks like the following...

<table width="100%" >
<tr class="odd">
<td><img src="icn_pdf.gif"></td>
<td><strong>Application Form</strong></td>
<td><a href="/Form.pdf" class="smd"></a></td>
</tr>
<tr>
<td><img src="icn_pdf.gif"></td>
<td><strong>Application Form</strong></td>
<td><a href="/Form.pdf" class="smd"></a></td>
</tr>
<tr class="odd">
<td><img src="icn_pdf.gif"></td>
<td><strong>Application Form</strong></td>
<td><a href="/Form.pdf" class="smd"></a></td>
</tr>
<tr>
<td><img src="icn_pdf.gif"></td>
<td><strong>Application Form</strong></td>
<td><a href="/Form.pdf" class="smd"></a></td>
</tr>
</tbody></table>


Currently you can see each 'document' on each row. What i want to do via jquery is loop through and have two rows with two documents in. so 6 tds in each row?

Answer

Please check this fiddle link. http://jsfiddle.net/MgSsy/

$(function() {
    $('table tr:odd').each(function() {
        $this = $(this);
        $this.prev().append(($this.html()));
        $this.remove();
    });
});‚Äč

I think this is what you want.

I did this as per my understanding about your code.