JavaScript 表格高亮类的应用[高级]
表格高亮
* {
font-size: 11px;
font-family: verdana, arial, sans-serif;
}
table {
border: 1px solid #ccc;
margin: 0 auto;
}
th {
background-color: #f7f7f7;
}
td, th {
padding: 15px;
border: 1px solid #ccc;
}
tr.alternate {
background-color: #efd;
}
.bold {
font-weight: bold;
}
.red {
color: red;
font-weight: bold;
}
.blue {
background-color: blue;
}
/* Used with crosshairs.js */
.hoverHilight {
background-color: #ffffc0;
cursor: pointer;
}
.activeCellHilight {
background-color: #c0dbff;
color: blue;
}
var hilightClass = "hoverHilight";
var activeHilightClass = "activeCellHilight";
var hilightActive = 1;
var hilightCol = 1;
var hilightRow = 1;
var hilightTopHeader = 0;
var hilightLeftHeader = 0;
var hilightRightHeader = 0;
var hilightBottomHeader = 0;
var surroundActive = 0;
function initCrossHairsTable(id, topPad, rightPad, bottomPad, leftPad) {
var tableObj = document.getElementById(id);
var c = tableObj.rows[0].cells.length - rightPad;
var r = tableObj.rows.length - bottomPad;
for (var i = topPad; i
编号 | 姓名 | 地址 | 电话 | |
---|---|---|---|---|
1 | a1 | b1 | c1 | d1 |
2 | a2 | b2 | c2 | d2 |
3 | a3 | b3 | c3 | d3 |
4 | a4 | b4 | c4 | d4 |
5 | a5 | b5 | c5 | d5 |
initCrossHairsTable("crossTable", 1, 0, 0, 1);//控制
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]