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

Javascript
javascript显弹效果代码增加了cookies控制
通过修改referer下载文件的方法
js简单的表拖拽
javascript Error 对象 错误处理
[原创]discuz中用到的javascript函数解析
js 加载时自动调整图片大小
JS入门代码集合
css客齐集社区头像显示效果
使用jscript实现二进制读写脚本代码
国外的为初学者写的JavaScript教程
比较详细的javascript DOM 学习笔记
符合W3C Web标准的图片连续无间隙水平滚动
Javascript入门学习第五篇 js函数
点图片上一页下一页翻页效果
js鼠标、键盘事件实例代码
JavaScript 图片切换展示效果alibaba拓展版
Javascript 小技巧全集
两表格传递变量
收集整理的四个方向的滚动
可拖动窗口,附带鼠标控制渐变透明,开启关闭功能

Javascript 中的 Expandable "Detail" Table Rows


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