1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 3 <head> 4 <title></title> 5 <style> 6 table { border:0;border-collapse:collapse;} 7 td { font:normal 12px/17px Arial;padding:2px;width:100px;} 8 th { font:bold 12px/17px Arial;text-align:left;padding:4px;border-bottom:1px solid #333;width:100px;} 9 .parent { background:#FFF38F;cursor:pointer;} /* 偶数行样式*/ 10 .odd { background:#FFFFEE;} /* 奇数行样式*/ 11 .selected { background:#FF6500;color:#fff;} 12 </style> 13 <!-- 引入jQuery --> 14 <script src="http://www.gamejzy.com/js/jquery.js" type="text/javascript"></script> 15 <script type="text/javascript"> 16 $(function(){ 17 $('tr.parent').click(function(){ // 获取所谓的父行 18 $(this) 19 .toggleClass("selected") // 添加/删除高亮 20 .siblings('.child_'+this.id).toggle(); // 隐藏/显示所谓的子行 21 }).click(); 22 }) 23 </script> 24 </head> 25 <body> 26 <table> 27 <thead> 28 <tr><th>姓名</th><th>性别</th><th>暂住地</th></tr> 29 </thead> 30 <tbody> 31 <tr class="parent" id="row_01"><td colspan="3">前台设计组</td></tr> 32 <tr class="child_row_01"><td>张山</td><td>男</td><td>浙江宁波</td></tr> 33 <tr class="child_row_01"><td>李四</td><td>女</td><td>浙江杭州</td></tr> 34 35 <tr class="parent" id="row_02"><td colspan="3">前台开发组</td></tr> 36 <tr class="child_row_02"><td>王五</td><td>男</td><td>湖南长沙</td></tr> 37 <tr class="child_row_02"><td>找六</td><td>男</td><td>浙江温州</td></tr> 38 39 <tr class="parent" id="row_03"><td colspan="3">后台开发组</td></tr> 40 <tr class="child_row_03"><td>Rain</td><td>男</td><td>浙江杭州</td></tr> 41 <tr class="child_row_03"><td>MAXMAN</td><td>女</td><td>浙江杭州</td></tr> 42 </tbody> 43 </table> 44 </body> 45 </html>