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

Javascript
MooTools教程(3):数组管理DOM元素
MooTools教程(4):函数和MooTools
MooTools教程(5):事件处理
MooTools教程(6):操纵HTML DOM元素
MooTools教程(7):设置和获取样式表属性
MooTools教程(8):输入过滤-数字
MooTools教程(9):输入过滤-字符串
MooTools教程(10):Fx.Tween渐变
MooTools教程(11):Fx.Morph、Fx选项和Fx事件
MooTools教程(12):Drag.Move来实现拖放
MooTools教程(13):正则表达式
MooTools教程(14):定时器和Hash对象
MooTools教程(15):滚动条(Slider)
浏览器对Cookie的限制
图片不间断滚动的特效代码详细讲解
Javascript教程:拖放效果研究
不唐突的JavaScript
JavaScript教程:图片切割效果
认识AJAX了解AJAX优点缺点和运用
网页投票系统中的限制

Javascript 中的 Expandable "Detail" Table Rows


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