JavaScript Tutorial: onmouseover controls Images
<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.tar get;
Source. className = "imgActive ";
}
Function imgOutListener (event)
{
Var event = event | window. event;
Var source = event. srcElement | event.tar get;
Source. className = "";
}
-->
</Script>
</Head>
<Body onLoad = "attachImgEventListener ()">
<Div id = "MM">
</Div>
</Div>
</Body>
</Html>
This article is from: webpage tutorial Network (www.webjx.com)