网站制作学习网JS脚本→正文:onmouseover控制图片
字体:

onmouseover控制图片

JS脚本 2008/1/4 8:22:06  点击:不统计

< 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.forasp.cn/images/common/XML.gif" width="50px" height="50px">

< img src="http://www.forasp.cn/images/common/xml.gif" width="50px" height="50px">

< img src="http://www.forasp.cnimages/common/xml.gif" width="50px" height="50px">

< img src="http://www.forasp.cn/images/common/xml.gif" width="50px" height="50px">

< /div>

< img src="http://www.forasp.cn/images/common/xml.gif" width="50px" height="50px">

< img src="http://www.forasp.cn/images/common/xml.gif" width="50px" height="50px">

< img src="http://www.forasp.cn/images/common/xml.gif" width="50px" height="50px">

< img src="http://www.forasp.cn/images/common/xml.gif" width="50px" height="50px">

< /div>

< /body>

< /html>

·上一篇:设置打印 >>    ·下一篇:JavaScript页面刷新与弹出窗口问题解决方法 >>
推荐文章
最新文章