鼠标移动行内变色JavaScript代码
1。 protected void GVpar_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
////鼠标经过时,行背景色变
//e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E6F5FA'");
////鼠标移出时,行背景色变
//e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
e.Row.Attributes.Add("onmouseover", "onmOer(this)");
e.Row.Attributes.Add("onmouseout", "onmOut(this)");
//e.Row.Attributes.Add("onclick", "rowClick('" + this.GV_Module.DataKeys[e.Row.RowIndex].Value + "')");
}
}
2. protected void GV_Config_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "onmOer(this)");
e.Row.Attributes.Add("onmouseout", "onmOut(this)");
}
}
function onmOer(tr){
currentcolor = tr.style.backgroundColor;
tr.style.backgroundColor='#F
tr.style.cursor='hand';
}
function onmOut(tr){
tr.style.backgroundColor=currentcolor
}