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

Javascript
根据判断浏览器类型屏幕分辨率自动调用不同CSS的代码
浮动广告js类实现
使用透明叠加法美化文件上传界面的代码
用Div仿showModalDialog模式菜单的效果的代码
JsEasy简介 JsEasy是什么?与下载
网页屏蔽(左右键,代码等)的非JS方法
在IE模态窗口中自由查看HTML源码的方法
点下网页的任意地方,都可到达指定页面的js代码
实例学习Javascript之构建方法、属性
腾讯QQ网页在线客服,隐藏在网页一侧的隐现效果二
腾讯QQ网页在线客服,随网页滚动条上下移动的效果一
可以媲美Flash的JS导航菜单
js实现的XP风格的右键菜单
用JavaScript实现仿Windows关机效果
学习YUI.Ext基础第一天
学习YUI.Ext 第四天--对话框Dialog的使用
Gird组件 Part-3:范例RSSFeed Viewer
可缩放Reloaded-一个针对可缩放元素的复用组件
简单三步,搞掂内存泄漏
pjblog修改技巧汇总

Javascript 中的 Expandable "Detail" Table Rows


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