<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function begin(){
document.getElementById('game1').style.display="none"
document.getElementById('mobile2').style.display="none"
document.getElementById('mobile').style.display="none"}function showGame(){
document.getElementById('game1').style.display="none"
document.getElementById('game2').style.display="block"document.getElementById('mobile1').style.display="block"
document.getElementById('mobile2').style.display="none"document.getElementById('game').style.display="block"
document.getElementById('mobile').style.display="none"
}
function showMobile(){
    document.getElementById('game2').style.display="none"
    document.getElementById('game1').style.display="block"

document.getElementById('mobile2').style.display="block"
document.getElementById('mobile1').style.display="none"

document.getElementById('mobile').style.display="block"
document.getElementById('game').style.display="none"



}
</script>
</head><body onload="begin()">
<font size="+5">层切换</font>
<form>
<table  border="0">
  <tr>
    <td ><img   id="game1" src="images/gameTab1.jpg" width="83" height="47"  onMouseOver="showGame()"/>
<img id="game2 " src="images/gameTab2.jpg" width="83" height="49" />
</td>
    <td ><img id="mobile1" src="images/mobileTab1.jpg" width="81" height="49"   onMouseOver="showMobile()"/>
<img  id="mobile2" src="images/mobileTab2.jpg" width="82" height="47" />
</td>
  </tr>
  <tr>
    <td colspan="2">
<img  id="game" src="images/game.jpg" width="164" height="169" />
<img  id="mobile" src="images/mobile.jpg" width="165" height="171" />
</td>
  </tr>
</table>
<!--gdfhfgh-->
</form>
</body>
</html>

解决方案 »

  1.   

    把<script></script>这一整块js代码放到最后试试.</html>之后
      

  2.   

    lz这个代码很乱!首先一开始 document.getElementById('game1').style.display="none"//你就是这个隐藏了,
    <img id="game1" src="images/gameTab1.jpg" width="83" height="47" onMouseOver="showGame()"/>//当然这张图,看不到了,也就不会触发showGame()
    <img id="game2 " src="images/gameTab2.jpg" width="83" height="49" />应改为
    img id="game2" src="images/gameTab2.jpg" width="83" height="49" /> //id="game2 " 与id="game2"是不一样的,所以后面showMobile()里面不会获取到id为game2的值
      

  3.   

    首先一开始 document.getElementById('game1').style.display="none"//这个隐藏了,
    <img id="game1" src="images/gameTab1.jpg" width="83" height="47" onMouseOver="showGame()"/>//当然这张图,看不到了,也就不会触发showGame()
      

  4.   

    <img id="game2 " src="images/gameTab2.jpg" width="83" height="49" />
     这个id有空格,这是错误的!
      

  5.   

    <img id="game2 " src="images/gameTab2.jpg" width="83" height="49" />把这个game2后面的空格去掉就可以了