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

Javascript
写的htc的数据表格
幻宇的层模拟窗口效果-提供演示和下载
javascript 播放器 控制
一个无限级XML绑定跨框架菜单(For IE)
innerHTML,outerHTML,innerTEXT三者之间的区别
无间断滚动的新闻文章列表 多浏览器兼容
图片连续不间断滚动像册
关于图片验证码设计的思考
Js之软键盘实现(js源码)
js技巧收集(200多个) 超强推荐
图片自动播放也可通过按钮控制显示
照片各部分的彩色与黑白交替更换
select发展史 超强
无聊,写了个日历程序,欢迎拍砖
greybox:不开新窗口看新的网页
nicejforms:美化表单不用愁
用jquery来定位
动态调用css文件:jquery的应用
用YUI做了个标签浏览效果
JS轻松实现CSS设置,DIV+CSS常用CSS设置

Javascript 中的 Expandable "Detail" Table Rows


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