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

Javascript
javascript 实现的类似hao123的多邮箱登录效果
不错的用resizeTo和moveTo两个函数实现窗口的“打乒乓球”效果
出现“不能执行已释放的Script代码”错误的原因及解决办法
“不能执行已释放的Script代码”错误的原因及解决办法
javascript入门·对象属性方法大总结
javascript入门·动态的时钟,显示完整的一些方法,新年倒计时
JavaScript 入门·JavaScript 具有全范围的运算符
用javascript实现代替marquee的滚动字幕效果代码
[原创]仿google adsense颜色选择器代码,从中易广告联盟程序提取
greenbrower用到的function.js代码集合
javascript flash下fromCharCode和charCodeAt方法使用说明
内部的小页面,用层制作,随机变色
javascript简写效果“神秘的眼睛”
用js写“算24”游戏的思路分析与实现代码
[原创]js循环输出图片,不足的要补0
json简单介绍
javascript 获取网页参数系统
[原创]js判断ie方法集锦(含正则)代码短小经典
javascript SocialHistory 检查访问者是否访问过某站点
[原创]js判断是否有中文的脚本_js判断中文方法集合

Javascript 中的 Expandable "Detail" Table Rows


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