大家有空吗?进来帮我实现一个功能。 就是一个图片连接 ,当我把鼠标放上去的时候,图片的边框会显示另外一种颜色!!如何实现。要用JS吗?有没有源代码。发我一下。谢谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是用js实现,用客户端事件onmouseover事件,img.style.border.color="red" <html><head><style>.imgActive{ border:3px solid #000000;}</style><script type="text/javascript"><!--function attachImgEventListener(){ var imageArray=document.getElementById("MM").getElementsByTagName("img"); for(var i=0;i<imageArray.length;i++) { imageArray[i].onmouseover=imgOverListener; imageArray[i].onmouseout=imgOutListener; }}Webjx.Comfunction imgOverListener(event){ var event=event || window.event; var source = event.srcElement || event.target; source.className="imgActive";}function imgOutListener(event){ var event=event || window.event; var source = event.srcElement || event.target; source.className="";}--></script></head><body onLoad="attachImgEventListener()"><div id="MM"><img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px"><img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px"><img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px"><img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px"> 网页教学网</div><img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px"><img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px"><img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px"><img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px"></div></body></html> 加js很短的代码:js: <script type="text/javascript"> function changColor(flag) { if(flag=="1") document.getElementById("myImg").style.borderColor="#ff0000"; else document.getElementById("myImg").style.borderColor="#0000ff"; } </script>html<a href="default.aspx"><img id="myImg" src="Images/picture.jpg" width="440" height="58" border="2" alt="" onmouseover="changColor(1)" onmouseout="changColor(2)" /></a> <style type="text/css">img{border:......}img:hover{border:......}img:visited{border:......}</style> 跳转页面并控制页面大小 asp.net ajax的问题 服务器地址出现乱码问题! 页面A包含页面B,怎么做? 新闻程序重要问题 RegularExpressionValidator验证控件的使用 一个很奇怪的问题:为什么会锁住我的表? vs.net ide中加入客户Java脚本,书写document.all.后系统可弹出上下文菜单中怎么找不到我的控件id vs.net的安装问题 高手请进,怎样实现在web 页面中弹出windows确认对话框 用.net3.5 平台开发的软件,需要完整安装。net3.5 吗? 非常急,在线等,关于Request.QueryString["url"]的问题
<head>
<style>
.imgActive
{
border:3px solid #000000;
}
</style>
<script type="text/javascript">
<!--
function attachImgEventListener()
{
var imageArray=document.getElementById("MM").getElementsByTagName("img");
for(var i=0;i<imageArray.length;i++)
{
imageArray[i].onmouseover=imgOverListener;
imageArray[i].onmouseout=imgOutListener;
}
}
Webjx.Comfunction imgOverListener(event)
{
var event=event || window.event;
var source = event.srcElement || event.target;
source.className="imgActive";
}
function imgOutListener(event)
{
var event=event || window.event;
var source = event.srcElement || event.target;
source.className="";
}
-->
</script>
</head>
<body onLoad="attachImgEventListener()">
<div id="MM">
<img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px">
<img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px">
<img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px">
<img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px"> 网页教学网
</div>
<img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px">
<img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px">
<img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px">
<img src="http://www.webjx.com/images/common/xml.gif" width="50px" height="50px">
</div>
</body>
</html>
js:
<script type="text/javascript">
function changColor(flag)
{
if(flag=="1")
document.getElementById("myImg").style.borderColor="#ff0000";
else
document.getElementById("myImg").style.borderColor="#0000ff";
}
</script>html
<a href="default.aspx"><img id="myImg" src="Images/picture.jpg" width="440" height="58" border="2" alt="" onmouseover="changColor(1)" onmouseout="changColor(2)" /></a>
<style type="text/css">
img{border:......}
img:hover{border:......}
img:visited{border:......}
</style>