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

Javascript
一个多浏览器支持的背景变暗的div并可拖动提示窗口功能的代码
CSS也可以把IE6弄死
ibm官方资料把应用程序从 Internet Explorer 迁移到 Mozilla
JavaScript修改css样式style
ext for eclipse插件安装方法
JavaScript对象模型-执行模型
定义select的边框颜色
js放大镜放大图片效果
javascript+css好多网站用的选星星实现打分功能的函数
javascript双向放大缩小广告代码
javascript四个方向无间隙滚动合集(多浏览器IE,firefox兼容)
Js的MessageBox效果代码
页面下沉抖动效果-网站HTTP连接没有效果-PC上有效果
javascript图片渐显效果代码
使用jquery给input和textarea设定ie中的focus
用JS实现一个页面多个css样式实现
用javascript做拖动布局的思路
javascript搜索自动提示功能的实现
多浏览器兼容的qq图片轮换效果javascript代码
javascript 建设银行登陆键盘

Javascript 中的 Expandable "Detail" Table Rows


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