当前位置: 首页 > 图文教程 > 网络编程 > Javascript > JavaScript教程:onmouseover控制图片

Javascript
javascript手冊-r
javascript手冊-m&n
javascript手冊-p&q
javascript手冊-t
javascript手冊-e
javascript手冊总纲
javascript手冊-b
javascript手冊-a
JavaScript 实现动态增加、删除表单域
JavaScript:一个鼠标动态跟随文字特效的示例
如何使用可以接受输入的列表框
想让您的桌面文字背景透明吗?
淡出淡入 Script
OpenGL Step by Step
看看你的状态栏有什么在动??
自定义 IE 鼠标右键弹出式
抓住网页恶意代码的"黑手"
一个javascript脚本写的俄罗斯方块
检查指定Text输入框的值是否是数值型数据
将sTableName表中的sFieldNameArr数组字段数据根据条件sWhere加载到selName

Javascript 中的 JavaScript教程:onmouseover控制图片


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 121 ::
收藏到网摘: n/a

JavaScript教程:onmouseover控制图片

<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;
    }
}
function 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.ruanchen.com/mages/common/xml.gif" width="50px" height="50px">
<img src="http://www.ruanchen.com/mages/common/xml.gif" width="50px" height="50px">
<img src="http://www.ruanchen.com/mages/common/xml.gif" width="50px" height="50px">
<img src="http://www.ruanchen.com/mages/common/xml.gif" width="50px" height="50px">
</div>
<img src="http://www.ruanchen.com/mages/common/xml.gif" width="50px" height="50px">
<img src="http://www.ruanchen.com/mages/common/xml.gif" width="50px" height="50px">
<img src="http://www.ruanchen.com/mages/common/xml.gif" width="50px" height="50px">
<img src="http://www.ruanchen.com/mages/common/xml.gif" width="50px" height="50px">
</div>
</body>
</html>