显示隐藏菜单

<!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 showInfo(str){
		//先隐藏所有
		for(var i = 1; i <= 3; i++){
			document.getElementById("tr"+i).style.display="none";
		}
		//显示指定对象
		document.getElementById(str).style.display="block";
	}
</script>
</head>

<body>
<table width="166" border="1">
  <tr>
    <td height="22" style="cursor:pointer;" onclick="showInfo('tr1')">ExtJs教程</td>
  </tr>
  <tr id="tr1">
    <td height="65" valign="top"><table width="100%" border="0">
      <tr>
        <td>第一讲</td>
      </tr>
      <tr>
        <td>第二讲</td>
      </tr>
      <tr>
        <td>第三讲</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="22" style="cursor:pointer;" onclick="showInfo('tr2')">css教程</td>
  </tr>
  <tr id="tr2" style="display:none;">
    <td height="65" valign="top"><table width="100%" border="0">
      <tr>
        <td>第一讲</td>
      </tr>
      <tr>
        <td>第二讲</td>
      </tr>
      <tr>
        <td>第三讲</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="23" style="cursor:pointer;" onclick="showInfo('tr3')">JavaEE教程</td>
  </tr>
  <tr id="tr3" style="display:none;">
    <td height="65" valign="top"><table width="100%" border="0">
      <tr>
        <td>第一讲</td>
      </tr>
      <tr>
        <td>第二讲</td>
      </tr>
      <tr>
        <td>第三讲</td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>

你可能感兴趣的:(显示隐藏菜单)