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を介して実行したいのは、ループスルーし、2つのドキュメントが含まれる2つの行があることです。したがって、各行に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 に答える