Html Tables - Can I Have An Additional Tbody Before The Thead?
Solution 1:
You can use multiple rows in <thead>
like this:-
<table>
<thead>
<tr> <td>1</td> <td>1</td> </tr>
<tr> <td>head</td> <td>head</td> </tr>
</thead>
</table>
Solution 2:
I recommend that you use an id (#) marker to identify that part that you want the js to work off and have the js use that id.
With that, have the thead
first and the tbody
last.
The variations you are describing may work - in the browser you using now, on the OS you are ok - and may be compliant a certain version of the HTML spec- but putting things in an unusual order is (in my expereince) just the kind of thing to not work, or work the same, everywhere and to eventually be the cause of much frustration, especially as the site grows in complexity.
Solution 3:
One solution is to use another table inside one tr, in your thead. Althought, this is a totally ugly solution.
You can also place a div above your table using CSS.
Solution 4:
Correct table structure is:
<table>
<thead>
<tr>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
<tfoot>
<tr>
<th></th>
<th></th>
</tr>
</tfoot>
</table>
<thead>
will always be on the top and <tfoot>
will always be at the bottom.
Using jQuery
you can swap <thead>
and <tbody>
content by:
$(document).ready(function() {
$('#myTrigger').click(function() {
var top = $('thead').html();
var mid = $('tbody').html();
$('thead').html(mid);
$('tbody').html(top);
});
});
Post a Comment for "Html Tables - Can I Have An Additional Tbody Before The Thead?"