开发者

Preventing a table's headers from being sortable using JQuery Sortable plug-In

开发者 https://www.devze.com 2023-01-08 19:41 出处:网络
I have an HTML table: <table id=\"HatedByCSSOnlyGoons\"> <tr><td>Header开发者_JAVA百科 1</td><td>Header 2</td></tr>

I have an HTML table:

<table id="HatedByCSSOnlyGoons">
   <tr><td>Header开发者_JAVA百科 1</td><td>Header 2</td></tr>
   <tr><td>Data</td><td>Data</td></tr>
   <tr><td>Data</td><td>Data</td></tr>
</table>

and I'm applying the JQuery Sortable plug-In:

<script language="javascript">
    $(document).ready(
        function() {

            $("#HatedByCSSOnlyGoons tbody").sortable();

            $("#HatedByCSSOnlyGoons tbody").disableSelection();

        }

    );
</script>

Question: I want every table row after the first(since this is the one with the table headers) to be sortable. How do I limit the scope of sortable()?


Put the column headers in the <thead> tag and change the header cells from <td> to <th>:

<table id="HatedByCSSOnlyGoons">
   <thead>
       <tr><th>Header 1</th><th>Header 2</th></tr>
   </thead>
   <tbody>
       <tr><td>Data</td><td>Data</td></tr>
       <tr><td>Data</td><td>Data</td></tr>
   </tbody>
</table>
0

精彩评论

暂无评论...
验证码 换一张
取 消