zoukankan
html css js c++ java
GridView鼠标移动行变色
方法一:
在GridView的
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
{
e.Row.Attributes.Add(
"
onMouseOver
"
,
"
SetNewColor(this);
"
);
e.Row.Attributes.Add(
"
onMouseOut
"
,
"
SetOldColor(this);
"
);
}
}
在页面中加入
<
SCRIPT language
=
javascript
>
var _oldColor;
function SetNewColor(source)
{
_oldColor
=
source.style.backgroundColor;
source.style.backgroundColor
=
'
#666666
'
;
}
function SetOldColor(source)
{
source.style.backgroundColor
=
_oldColor;
}
</
SCRIPT
>
方法二:
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
{
e.Row.Attributes[
"
onMouseOver
"
]
=
"
js.ItemOver(this)
"
;
}
}
在页面上加入
<
SCRIPT language
=
javascript type
=
text
/
javascript
>
var js
=
new
function()
{
if
(
!
objbeforeItem)
{var objbeforeItem
=
null
;var objbeforeItembackgroundColor
=
null
;}
this
.ItemOver
=
function(obj)
{
if
(objbeforeItem)
{objbeforeItem.style.backgroundColor
=
objbeforeItembackgroundColor;}
objbeforeItembackgroundColor
=
obj.style.backgroundColor;
objbeforeItem
=
obj;
obj.style.backgroundColor
=
"
#fcfcfc
"
;
}
}
</
SCRIPT
>
方法三:
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
{
//
鼠标移动到每项时颜色交替效果
e.Row.Attributes.Add(
"
OnMouseOut
"
,
"
this.style.backgroundColor='White';this.style.color='#003399'
"
);
e.Row.Attributes.Add(
"
OnMouseOver
"
,
"
this.style.backgroundColor='#6699FF';this.style.color='#8C4510'
"
);
//
设置悬浮鼠标指针形状为"小手"
e.Row.Attributes[
"
style
"
]
=
"
Cursor:hand
"
;
}
}
//
----------------------------------------
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
//
判断是否是DataRow,以防止鼠标经过Header也有效果
{
e.Row.Attributes.Add(
"
onmouseover
"
,
"
e=this.style.backgroundColor; this.style.backgroundColor='#cccccc'
"
);
e.Row.Attributes.Add(
"
onmouseout
"
,
"
this.style.backgroundColor=e
"
);
}
}
查看全文
相关阅读:
英语影视台词---经典电影台词(世间万物有始皆有终。)
js数组,字符串,json互相转换函数有哪些
php set_time_limit()的作用是什么
界面分析---如何做美观的网页
legend2---开发日志7(vue的使用场景有哪些,或者说使用的优缺点)
legend2---开发日志1(legend的数据库整体设计思路是什么)
legend2---开发日志2(注释和函数比较好的写法)
legend2---开发日志3(thinkphp的入口目录是public的体现是什么)
legend2---开发日志4(常用的链接传值方式有哪些)
BZOJ 1823 JSOI 2010 盛宴 2-SAT
原文地址:https://www.cnblogs.com/juan/p/1424642.html
最新文章
linux diff(differential) 命令
it is likely that the remote side declared peer gone on this jvm
深入redis内部---网络编程
java.net.SocketException四大异常解决方案---转
TCP/IP协议簇分层详解---转
ping 原理与ICMP协议---转
How to Install Eclipse C/C++ Development Tool--转
SVN命令行怎么用?--转百度知道
深入redis内部--事件处理机制
HDU 2844 Coins
热门文章
移动效果向导,旋转效果
具体评论ExpandableListView显示和查询模仿QQ组列表用户信息
Struts2+Spring+Hibernate step by step 11 ssh拦截验证用户登录到集成
【 D3.js 入门系列 --- 10.2 】 你可以拖动地图
ftp的port和pasv型号比较
pydev-python 链接mysql数据库(mac系统)
UIViewAdditions(一个非常方便的工具类用它)
数据库架构组件
程序猿知道英语词汇
英语常用句型37句(过去常做什么)
Copyright © 2011-2022 走看看