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

Javascript
js返回当前网页的url
简明json介绍
JavaScript在IE中“意外地调用了方法或属性访问”
JS获得鼠标位置(兼容多浏览器ie,firefox)修正版
JavaScript 基础问答 四
支持多浏览器(IE、Firefox、Opera)剪切板复制函数
js 解决“options为空或不是对象”
走出JavaScript初学困境—js初学
JavaScript入门教程(6) Window窗口对象
JavaScript 快捷键设置实现代码
Extjs Ajax 乱码问题解决方案
JavaScript 实现模态对话框 源代码大全
[原创]js 日期加红代码 适用于各种cms
论坛里点击别人帖子下面的回复,回复标题变成“回复 24# 的帖子”
[原创]javascript 改变字体大小方法集合
javascript 单行文字向上跑马灯滚动显示
一个简单的javascript类定义例子
javascript 类定义的4种方法
javascript类继承机制的原理分析
firefox(火狐)和ie浏览器禁止右键和禁止复制的代码

Javascript 中的 Expandable "Detail" Table Rows


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