求助javascript里onmouse事件的代码
本人完全菜鸟,不懂编程。摸索写了以下一段代码,求大神帮我精简,能无限添加table。顺便详细说明一下要替换的地方。感谢!新手入驻,分不多,请见谅!
代码如下:
<script type="text/javascript">
function mouseOver1()
{
document.getElementById('b1').src ="新建文件夹/QD020深蓝主图2.jpg"
}
function mouseOut1()
{
document.getElementById('b1').src ="新建文件夹/QD020深蓝主图1.jpg"
}
function mouseOver2()
{
document.getElementById('b2').src ="新建文件夹/QD059月蓝主图2.jpg"
}
function mouseOut2()
{
document.getElementById('b2').src ="新建文件夹/QD059月蓝主图1.jpg"
}
function mouseOver3()
{
document.getElementById('b3').src ="新建文件夹/QD073红色主图2.jpg"
}
function mouseOut3()
{
document.getElementById('b3').src ="新建文件夹/QD073红色主图1.jpg"
}
function mouseOver4()
{
document.getElementById('b4').src ="新建文件夹/QD073红色主图2.jpg"
}
function mouseOut4()
{
document.getElementById('b4').src ="新建文件夹/QD073红色主图1.jpg"
}
function mouseOver5()
{
document.getElementById('b5').src ="新建文件夹/QD073红色主图2.jpg"
}
function mouseOut5()
{
document.getElementById('b5').src ="新建文件夹/QD073红色主图1.jpg"
}
function mouseOver6()
{
document.getElementById('b6').src ="新建文件夹/QD073红色主图2.jpg"
}
function mouseOut6()
{
document.getElementById('b6').src ="新建文件夹/QD073红色主图1.jpg"
}
</script>
<table id="__01" width="990" height="330" border="0" cellpadding="0" cellspacing="0">
<tr>
<td >
<a onmouseover="mouseOver1()" onmouseout="mouseOut1()"><img src="新建文件夹/QD020深蓝主图1.jpg" width="330" height="330" alt="" id="b1"></a></td>
<td>
<a onmouseover="mouseOver2()" onmouseout="mouseOut2()"><img src="新建文件夹/QD059月蓝主图1.jpg" width="330" height="330" alt="" id="b2"></a></td>
<td >
<a onmouseover="mouseOver3()" onmouseout="mouseOut3()"><img src="新建文件夹/QD073红色主图1.jpg" width="330" height="330" alt="" id="b3"></a></td>
</tr>
</table>
<table id="__02" width="990" height="330" border="0" cellpadding="0" cellspacing="0">
<tr>
<td >
<a onmouseover="mouseOver4()" onmouseout="mouseOut4()"><img src="新建文件夹/QD020深蓝主图1.jpg" width="330" height="330" alt="" id="b4"></a></td>
<td>
<a onmouseover="mouseOver5()" onmouseout="mouseOut5()"><img src="新建文件夹/QD059月蓝主图1.jpg" width="330" height="330" alt="" id="b5"></a></td>
<td >
<a onmouseover="mouseOver6()" onmouseout="mouseOut6()"><img src="新建文件夹/QD073红色主图1.jpg" width="330" height="330" alt="" id="b6"></a></td>
</tr>
</table>