关于onmouseover,onmouseout,onclick这三个事件的问题【在线等】
有3组不同的图片,分别对应这三个时间。
<A onmouseover="MM_swapImage('Image1','','picture/zyfx1.GIF',1)" style="CURSOR: hand"
onclick="MM_click('Image1','','picture/zyfx2.GIF',2)" onmouseout="MM_swapImgRestore()"><IMG id="Image1" height="21" alt="" src="picture/zyfx.GIF" width="151"></A>
<A onmouseover="MM_swapImage('Image2','','picture/zyxxjy1.GIF',1)" style="CURSOR: hand" onclick="MM_click('Image2','','picture/zyxxjy2.GIF',2)"
onmouseout="MM_swapImgRestore()"><IMG id="Image2" height="21" alt="" src="picture/zyxxjy.GIF"
width="151"></A> <A onmouseover="MM_swapImage('Image3','','picture/zyhyy1.GIF',1)" style="CURSOR: hand"
onmouseout="MM_swapImgRestore()"><IMG id="Image3" height="21" alt="" src="picture/zyhyy.GIF" width="151"></A>
我用了这样的写法:
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
{
if(a[3]!=2)
{
x.src=x.oSrc;
}
else
{
}
}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_click()
{
var i,j=0,x,a=MM_click.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null)
{
document.MM_sr[j++]=x;
if(!x.oSrc)
x.oSrc=x.src;
x.src=a[i+2];
}
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null)
{
document.MM_sr[j++]=x;
if(!x.oSrc)
x.oSrc=x.src;
x.src=a[i+2];
}
}
如何使当选中一个图片选项(onclick事件)的时候,其他图片被处于未选中状态;
被选中的图片在鼠标移出的时候还是保持其被选中状态,未发生onclick事件的图片还是触发onmouseout事件。