jQuery实现table表格信息的展开和缩小功能示例

困难是动摇者和懦夫掉队回头的便桥;但也是勇敢者前进的脚踏石。我不识何谓君子,但看每事肯吃亏者便是;我不识何谓小人,但看每事好占便宜者便是。

本文实例讲述了jQuery实现table表格信息的展开和缩小功能。分享给大家供大家参考,具体如下:

<%@ page language="java"import="java.util.*"pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN">
<html>
 <head>
  <base rel="nofollow noopener noreferrer" href="<%=basePath%>" rel="external nofollow" >
  <title>My JSP 'index4.jsp' startingpage</title>
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="0">
  <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
  <meta http-equiv="description" content="This is my page">
  <link rel="stylesheet" type="text/css" rel="nofollow noopener noreferrer" href="css/index9.css" rel="external nofollow" >
  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  </head>
  <body>
  <table width="200px" height="100px" border="1">
  <tr>
  <td>编号</td>
  <td>姓名</td>
  <td>成绩</td>
  </tr>
  <tr align="left" class="parent" id="row1"><td colspan="3">学生信息</td></tr>
  <tr class="child_row1">
  <td>001</td>
  <td>小明</td>
  <td>80</td>
  </tr>
  <tr class="child_row1">
  <td>002</td>
  <td>张三</td>
  <td>79</td>
  </tr>
  </table>
  <script type="text/javascript">
  $(function() {
  $("tr.parent").click(function() {
  $(this).toggleClass("selected").siblings('.child_'+this.id).toggle(); 
  });
});
  </script>
  </body>
</html>

运行效果如下

希望本文所述对大家jQuery程序设计有所帮助。

以上就是jQuery实现table表格信息的展开和缩小功能示例。两名工人折腾了半天,仍未能将这个沉重的箱子移动半步。最后,在门内的工人连连叹气:我看还是放弃吧,我们真的无法将这个箱子搬出去了。搬出来?更多关于jQuery实现table表格信息的展开和缩小功能示例请关注haodaima.com其它相关文章!

标签: jQuery table