zoukankan      html  css  js  c++  java
  • griview点击后变色

      <script type="text/javascript">      

      var prevselitem = null;       

    function selectx(row) {                        

    //           if (prevselitem != null) {

    //               prevselitem.style.backgroundColor = '#ffffff'; //           }          

       row.style.backgroundColor = 'PeachPuff';           

      prevselitem = row;

           }      </script>

     <asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" Width="100%"
                    CssClass="grid" OnRowDataBound="gv_RowDataBound">

    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)    

    {        

           //首先判断是否是数据行      if (e.Row.RowType == DataControlRowType.DataRow)      

          {             e.Row.Attributes.Add("onclick", e.Row.ClientID.ToString() + ".checked=true;selectx(this)");//点击行变色       

                    //  e.Row.Attributes.Add("onmouseover", "if(this!=prevselitem){this.style.backgroundColor='#Efefef'}");//当鼠标停留时更改背景色          

                    //  e.Row.Attributes.Add("onmouseout", "if(this!=prevselitem){this.style.backgroundColor='#ffffff'}");//当鼠标移开时还原背景色

            }

        }

  • 相关阅读:
    PHP jquery结合HTML5鼠标拖选头像图片并上传
    HTML5 CSS3 SwitchButton 自定义Radio风格
    IE浏览器在虚拟机中无法正常显示字符
    jQuery在updatepanel中使用造成内存泄露
    bootstrap下拉列表重置联动
    bootstrap正则表达式验证手机 座机 邮箱
    bootstrap重置校验方法
    分页
    函数解一元二次方程
    集合
  • 原文地址:https://www.cnblogs.com/heqianjin/p/3332622.html
Copyright © 2011-2022 走看看