开发者

How to split <table> with jQuery on the fly?

开发者 https://www.devze.com 2023-03-21 14:56 出处:网络
In order to expose one particular TBODY with cross-browser support, I need to split my <table> to 3 tables on the fly and expose the middle one. Is it possible without rebuilding a whole table?

In order to expose one particular TBODY with cross-browser support, I need to split my <table> to 3 tables on the fly and expose the middle one. Is it possible without rebuilding a whole table? Anyone knows relevant tutorials that could help to make it efficiently?

Example. Initially:

<table>
<tbody>
      <tr><td></td></tr>
        ....
</tbody> 
<tbody>
      <tr><td></td></tr>
        ....
</tbody>
<tbody>
      <tr><td></td></tr>
        ....
</tbody>
</table>

Result:

<table>
<tbody>
      <tr><td></td></tr>
        ....
</tbody>
</table>
<table> 
<tbody>
      <tr><td></td></tr>
       开发者_如何学C ....
</tbody>
</table>
<table>
<tbody>
      <tr><td></td></tr>
        ....
</tbody>
</table>


Not sure this is what you are after, but you could to the following with jQuery.

$('tbody').hide();
$('tbody:odd').show();

http://jsfiddle.net/jasongennaro/NybeH/

This hides all the tbody elements and then shows only the odd ones. Fyi... odd works here because it's a zero-based count.

0

精彩评论

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

关注公众号