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

Javascript
一个js写的日历(代码部分网摘)
IE,firefox(火狐)浏览器无提示关闭窗口js实现代码小结
jquery 子窗口操作父窗口的代码
用JavaScript隐藏控件的方法
js 冒泡事件与事件监听使用分析
ie与ff下的event事件
比较全面的event对像在IE与FF中的区别 推荐
js 获取中文拼音,Select自动匹配字母获取值的代码
JavaScript 变量命名规则
没有form表单情况下敲回车键提交表单的js代码
jQuery 使用手册(四)
jQuery 使用手册(六)
jQuery 使用手册(七)
Javascript 数组添加一个 indexOf 方法的实现代码
Javascript 数组添加 shuffle 方法的实现代码
Javascript 两个窗体之间传值实现代码
Javascript showModalDialog两个窗体之间传值
js 覆盖和重载 函数
JavaScript中Object和Function的关系小结
javascript parseInt 大改造

Javascript 中的 Expandable "Detail" Table Rows


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