在头部定义函数,放在<header>和</header>之间:
<script language="javascript">
function picShow(nwhich){
if(!document.getElementById) return;
if(nwhich==2)
{
document.getElementById('whichpic').src="images/sbei.jpg";
}
else
{
document.getElementById('whichpic').src="images/hj.jpg";
}
}
</script>
在<body></body>内部调用函数:
<div class="content_all" style="background:#f7f2ee; *margin-top:-6px;">
<div class="content_z" style="background:url(images/con6_2.jpg) no-repeat; height:447px;position:relative;">
<p style="position:absolute;top:5%; left:13%; font-size:30px;">
<a onMouseOver="picShow(1)">环境 </a>
<span> / </span>
<a onMouseOver="picShow(2)"> 设备</a>
</p>
<img src="./images/hj.jpg" id="whichpic" style="position:absolute;height=387px;width:955px;top:15%;left:11.5%;" />
</div>
</div>