jQuery将tbody Tag插入表中

时间:2013-11-29 09:28:54

标签: jquery html-table

如何在表格中插入tbody标签。 所以tbody必须覆盖“”标签

这是我的表:

<table id="contacts-table" data-role="table" data-mode="reflow" class="ui-responsive table-stroke ui-body-d ui-bar-d table-stripe ui-table ui-table-reflow">
    <thead>
        <tr id="contacts-head">
            <th data-priority="1">ID</th>
            <th data-priority="persist">Name</th>
            <th data-priority="2">Vorname</th>
            <th data-priority="3"><abbr title="Rotten Tomato Rating">E-Mail</abbr>
            </th>
            <th data-priority="4">Aktionen</th>
        </tr>
    </thead>


    <tr id="entry-16">
        <td><b class="ui-table-cell-label"></b>16</td>
        <td><b class="ui-table-cell-label"></b>Erolerer</td>
        <td><b class="ui-table-cell-label"></b>Babacan</td>
        <td><b class="ui-table-cell-label">aa@a.com</td>
        <td><b class="ui-table-cell-label"></b>Edit| Remove</a>
        </td>
    </tr>

</table>

应该是这样的:

    <table id="contacts-table" data-role="table" data-mode="reflow" class="ui-responsive table-stroke ui-body-d ui-bar-d table-stripe ui-table ui-table-reflow">
        <thead>
            <tr id="contacts-head">
                <th data-priority="1">ID</th>
                <th data-priority="persist">Name</th>
                <th data-priority="2">Vorname</th>
                <th data-priority="3"><abbr title="Rotten Tomato Rating">E-Mail</abbr>
                </th>
                <th data-priority="4">Aktionen</th>
            </tr>
        </thead>

   <tbody>
        <tr id="entry-16">
            <td><b class="ui-table-cell-label"></b>16</td>
            <td><b class="ui-table-cell-label"></b>Erolerer</td>
            <td><b class="ui-table-cell-label"></b>Babacan</td>
            <td><b class="ui-table-cell-label">aa@a.com</td>
            <td><b class="ui-table-cell-label"></b>Edit| Remove</a>
            </td>
        </tr>
    </tbody>

</table>

这是我的演示:http://jsfiddle.net/aldimeola1122/6Q2za/

我怎样才能实现这一目标? 提前谢谢

2 个答案:

答案 0 :(得分:1)

$(document).ready(function(){

  $('table #entry-16').wrap( "<tbody></tbody>" );

});

doc:http://api.jquery.com/wrap/

答案 1 :(得分:1)

$('#entry-16').wrap( "<tbody />" );
相关问题