0

我有一个如下所示的表...

<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>

目前,您可以在每一行上看到每个“文档”。我想通过jQuery做的是循环并有两行有两个文档。所以每行有6个tds?

4

2 回答 2

2

请检查这个小提琴链接。http://jsfiddle.net/MgSsy/

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

我想这就是你想要的。

根据我对您的代码的理解,我这样做了。

于 2012-08-02T09:06:02.250 回答
0
<script>
$(function() {

   $('#btn').on('click', fuction(){
     //adding to the first row
     $('#table tbody').prepend('<tr><td>...</td>...</tr>');

     //adding to the end
     $('#table tbody').append('<tr><td>...</td>...</tr>');

   }

});

于 2016-09-30T11:20:25.100 回答