jquery table展开 折叠效果
- 今天要做一个table的展开 折叠效果,想起以前自己收藏了一个,寻无果,索性自己做一个
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>无标题文档</title>
- <script language="javascript" type="text/javascript" src="jquery.js"></script>
- <script language="javascript" type="text/javascript">
- function show_and_hide_tr(tb_id, obj) {
- $("#" + tb_id).find("tr").each(function(i) {
- i > 0 ? (this.style.display == "none" ? this.style.display = "" : this.style.display = "none") : ($(this).next().css("display") == "none" ? (obj.value = "折叠") : (obj.value = "展开"));
- });
- }
- </script>
- </head>
- <body>
- <table id="tb1" style="width: 100%;" border="1">
- <tr>
- <th colspan="3">
- <input type="button" value="折叠" onclick="show_and_hide_tr('tb1',this);" />
- </th>
- </tr>
- <tr>
- <td>
- 作者:ikmb QQ:154179812
- </td>
- <td>
- 欢迎交流
- </td>
- <td>
- </td>
- </tr>
- <tr>
- <td>
- </td>
- <td>
- </td>
- <td>
- </td>
- </tr>
- </table>
- </body>
- </html>
版权声明:本文为ikmb原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。