使用方法之前先引入jquery.js文件。
Code
//反选所指定id元素内的所有复选框
///id:包含复选框的元素的id
function selectAllChk(id)
{
$("input:checkbox",$("#"+id)).each(function()
{
if(this.checked)
{
this.checked=false;
}
else
{
this.checked = true;
}
}
)
}
//改变表格隔行的颜色和鼠标放在行上改变背景
///id:指定表格id
function changeInterlacingColor(id)
{
$("#"+id+" tr:even").css("background-color","#E5F3F6");
$("#"+id+" tr").hover(
function()
{
if (this.cells[0].tagName != "TH")
{
this.style.background = "#b6d1ec";
}
}
, function()
{
if (this.cells[0].tagName != "TH")
{
if(this.rowIndex%2==0)
{
this.style.background = "#E5F3F6";
}
else
{
this.style.background = "white";
}
}
}
);
}
//反选所指定id元素内的所有复选框
///id:包含复选框的元素的id
function selectAllChk(id)
{
$("input:checkbox",$("#"+id)).each(function()
{
if(this.checked)
{
this.checked=false;
}
else
{
this.checked = true;
}
}
)
}
//改变表格隔行的颜色和鼠标放在行上改变背景
///id:指定表格id
function changeInterlacingColor(id)
{
$("#"+id+" tr:even").css("background-color","#E5F3F6");
$("#"+id+" tr").hover(
function()
{
if (this.cells[0].tagName != "TH")
{
this.style.background = "#b6d1ec";
}
}
, function()
{
if (this.cells[0].tagName != "TH")
{
if(this.rowIndex%2==0)
{
this.style.background = "#E5F3F6";
}
else
{
this.style.background = "white";
}
}
}
);
}
Code
function changeInterleaveColor(id)
{
$("#"+id+" tr:even").attr("class","normalEvenTD");//奇数行
$("#"+id+" tr:first").attr("class","t_h");//标题
$("#"+id+" tr:not(#"+id+" tr:first)").hover(
function()
{
this.className = "hoverTD";
}
, function()
{
if(this.rowIndex%2==0)
{
this.className="normalEvenTD";
}
else
{
this.className="normalOddTD";
}
}
);
}
function changeInterleaveColor(id)
{
$("#"+id+" tr:even").attr("class","normalEvenTD");//奇数行
$("#"+id+" tr:first").attr("class","t_h");//标题
$("#"+id+" tr:not(#"+id+" tr:first)").hover(
function()
{
this.className = "hoverTD";
}
, function()
{
if(this.rowIndex%2==0)
{
this.className="normalEvenTD";
}
else
{
this.className="normalOddTD";
}
}
);
}