<head>
<style>
.imgactive
{
border:3px solid #000000;
}
</style>
<script type="text/javascript">
<!--
function attachimgeventlistener()
{
var p_w_picpatharray=document.getelementbyid("mm").getelementsbytagname("img");
for(var i=0;i<p_w_picpatharray.length;i++)
{
p_w_picpatharray[i].onmouseover=imgoverlistener;
p_w_picpatharray[i].onmouseout=imgoutlistener;
}
}
111cn.cn
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.111cn.cn/p_w_picpaths/common/xml.gif" width="50px" height="50px">
<img src="http://www.111cn.cn/p_w_picpaths/common/xml.gif" width="50px" height="50px">
<img src="http://www.111cn.cn/p_w_picpaths/common/xml.gif" width="50px" height="50px">
<img src="http://www.111cn.cn/p_w_picpaths/common/xml.gif" width="50px" height="50px">
111cn.cn
</div>
<img src="http://www.111cn.cn/p_w_picpaths/common/xml.gif" width="50px" height="50px">
<img src="http://www.111cn.cn/p_w_picpaths/common/xml.gif" width="50px" height="50px">
<img src="http://www.111cn.cn/p_w_picpaths/common/xml.gif" width="50px" height="50px">
<img src="http://www.111cn.cn/p_w_picpaths/common/xml.gif" width="50px" height="50px">
</div>
</body>
</html>
本文链接:js onmouserover控制图片