日期:2014-05-16  浏览次数:20392 次

javascript 层的控制,下面不知哪错了
<!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>




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