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

Javascript
用jQuery解决IE不支持的option disable属性
jQuery 源代码显示控件 (Ajax加载方式).
JS backgroundImage控制
jQuery 性能优化指南 (1)
jQuery 性能优化指南(2)
jQuery 性能优化指南(3)
input+select(multiple) 实现下拉框输入值
javascript getBoundingClientRect() 来获取页面元素的位置的代码[修正版]
jQuery 图像裁剪插件Jcrop的简单使用
让GoogleCode的SVN下的HTML文件在FireFox下正常显示.
jquery(1.3.2) 斑马线效果代码
JQuery Jcrop 实现图片裁剪的插件
jquery img src 获取实现代码
javascript 历史记录 经常用于产品最近历史浏览
jquery tabs的实现代码
jQuery 剧场版 你必须知道的javascript
JavaScript 闭包深入理解(closure)
js 图片缩放(按比例)控制代码
广告切换效果(缓动切换)
javascript 用局部变量来代替全局变量

Javascript 中的 Expandable "Detail" Table Rows


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 361 ::
收藏到网摘: 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