JavaScript实现可自定义排序的表格 -
BODY {
FONT-SIZE: 0.8em; FONT-FAMILY: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif
}
P {
FONT-WEIGHT: bold; MARGIN-BOTTOM: 0px
}
.tableWidget_headerCell {
BORDER-RIGHT: #aca899 1px solid; BORDER-LEFT: #fff 1px solid; CURSOR: pointer; BORDER-BOTTOM: #c5c2b2 3px solid; BACKGROUND-COLOR: #ece9d8
}
.tableWigdet_headerCellOver {
BORDER-RIGHT: #aca899 1px solid; BORDER-LEFT: #fff 1px solid; CURSOR: pointer; BORDER-BOTTOM: #c5c2b2 3px solid; BACKGROUND-COLOR: #ece9d8
}
.tableWigdet_headerCellDown {
BORDER-RIGHT: #aca899 1px solid; BORDER-LEFT: #fff 1px solid; CURSOR: pointer; BORDER-BOTTOM: #c5c2b2 3px solid; BACKGROUND-COLOR: #ece9d8
}
.tableWidget_headerCell {
BORDER-TOP: #ece9d8 2px solid
}
.tableWigdet_headerCellOver {
BORDER-TOP: #ffc83c 2px solid
}
.tableWidget TBODY .tableWidget_dataRollOver {
BACKGROUND-COLOR: #fff
}
.tableWigdet_headerCellDown {
BORDER-RIGHT: #fff 1px solid; BORDER-TOP: #ffc83c 2px solid; BORDER-LEFT: #aca899 1px solid; BACKGROUND-COLOR: #dbd8c5
}
.tableWidget TD {
PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; MARGIN: 0px; PADDING-TOP: 2px; BORDER-BOTTOM: #eae9e1 1px solid
}
.tableWidget TBODY {
BACKGROUND-COLOR: #fff
}
.tableWidget {
FONT-SIZE: 12px; WIDTH: 400px; FONT-FAMILY: arial
}
DIV.widget_tableDiv {
BORDER-RIGHT: #aca899 1px solid; BORDER-TOP: #aca899 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #aca899 1px solid; WIDTH: 400px; BORDER-BOTTOM: #aca899 1px solid; HEIGHT: 200px
}
HTML > BODY DIV.widget_tableDiv {
OVERFLOW: hidden; WIDTH: 400px
}
.tableWidget THEAD {
POSITION: relative
}
.tableWidget THEAD TR {
BOTTOM: 0px; POSITION: relative; TOP: 0px
}
.tableWidget .scrollingContent {
OVERFLOW-Y: auto; WIDTH: 100%
}
Name
Age
Position
Income
Gender
John
37
Managing director
90.000
Male
Susan
34
Partner
90.000
Female
David
29
Head of production
70.000
Male
Laura
29
Head of marketing
70.000
Female
Kate
18
Marketing
50.000
Female
Mona
21
Marketing
53.000
Female
Mike
21
Marketing
53.000
Male
Mark
25
Production
52.000
Male
Peter
33
Production
55.000
Male
Jennifer
24
Production
49.000
Female
David
25
Photography
51.000
Male
Anna
42
Head of photography
56.000
Female
Rita
30
Photography
54.000
Female
Magnus
25
Freelancer
65.000
Male
Johnny
29
Freelancer
63.000
Male
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
推荐阅读
jQuery 表格工具集
jQuery 表格插件
Flexigrid – Web 2.0 Javscript Grid for jQuery - 可变列宽,自动适应表头宽度,可通过 Ajax 连接 XML 数据源,类似 Ext Grid,但基于 jQuery 因此更轻量小巧。
Chromatable JQuery Plugin - 固>>>详细阅读
本文标题:javascript table排序 这个更简单了,不用改变现在的表格结构
地址:http://www.17bianji.com/kaifa2/JS/26541.html
1/2 1