zoukankan      html  css  js  c++  java
  • GridView 鼠标经过时变色两种方法

    第一种:

     新建一个js文件 并引用

    1  <script src="jquery.js" type="text/javascript"></script>

    js文件内容如下:

     1 var _oldColor;      
     2 function SetNewColor(source)      
     3 {      
     4     _oldColor=source.style.backgroundColor;      
     5   
     6      source.style.backgroundColor='#F0F7FD';      
     7 }      
     8   
     9  function SetOldColor(source)      
    10 {      
    11     source.style.backgroundColor=_oldColor;      
    12 }

    给GridView添加RowDataBound事件

    1 protected void DGV_RowDataBound(object sender, GridViewRowEventArgs e)
    2 {
    3   if (e.Row.RowType == DataControlRowType.DataRow)
    4   {
    5      e.Row.Attributes.Add("onMouseOver", "SetNewColor(this);");
    6      e.Row.Attributes.Add("onMouseOut", "SetOldColor(this);");
    7   }
    8 }

    第二种:

    1 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    2 {
    3         if (e.Row.RowType == DataControlRowType.DataRow)
    4         {
    5             //高亮显示指定行
    6             e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#FFF000'");
    7             e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;");   
    8         }
    9 }
  • 相关阅读:
    nginx防止盗链
    Nginx防盗链详细设置
    [bzoj2127]happiness
    [bzoj2400]Optimal Marks
    [bzoj1738]发抖的牛
    [bzoj1741]穿越小行星群
    [bzoj3123]森林
    [bzoj2588]Count on a tree
    [bzoj3144]切糕
    [bzoj1787]紧急集合
  • 原文地址:https://www.cnblogs.com/haibing0107/p/5479034.html
Copyright © 2011-2022 走看看