当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Expandable "Detail" Table Rows

Javascript
JavaScript脚本:在网页中绘制图表
Jquery在实用和易学使用上的特点
网页制作之Javascript代码技巧
利用Java程序把Word文档转换成Html文件
提供gif icon制作的几个站点
JavaScript 实现 Konami Code
实用Javascript Tab导航插件23个
掌握JavaScript语言的思想前提
可以制作动画菜单效果的jquery插件
从脚本编程的角度看JSP的安全
JavaScript教程:伸缩菜单的制作
Javascript 代码也可以变得优美
与JavaScript新人共同分享实用经验
远程控制顺畅无阻碍-java来实现
Java开源的高性能缓存框架
通过代理访问因特网上的Web服务器
JavaScript基础教程:调试及应用
通过SSH交互进行Java应用开发
Java API编写自己的NamespaceContext
Java编程教程:SecureJSH特性简介

Javascript 中的 Expandable "Detail" Table Rows


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 133 ::
收藏到网摘: n/a

A common UI is to have a table of data rows, which when clicked on expand to show a detailed breakdown of "child" rows below the "parent" row.
The only requirements are:
Put a class of "parent" on each parent row (tr)
Give each parent row (tr) an id
Give each child row a class of "child-ID" where ID is the id of the parent tr that it belongs to
Example Code
$(function() {
$('tr.parent')
.css("cursor","pointer")
.attr("title","Click to expand/collapse")
.click(function(){
$(this).siblings('.child-'+this.id).toggle();
});
$('tr[@class^=child-]').hide().children('td');
});Example Table (click a row)

ID Name Total
123 Bill Gates 100
2007-01-02 A short description 15
2007-02-03 Another description 45
2007-03-04 More Stuff 40
456 Bill Brasky 50
2007-01-02 A short description 10
2007-02-03 Another description 20
2007-03-04 More Stuff 20
789 Phil Upspace 75
2007-01-02 A short description 33
2007-02-03 Another description 22
2007-03-04 More Stuff 20