<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>Insert title here</title>
<script language="javascript">
function lmenu(value){
switch(value){
case "新品":
submenu.innerHTML="<a href='#'>商品展示</a>|<a href='#'>销售排行榜</a>|<a href='#'>商品查询</a>";
break;
case "购物":
submenu.innerHTML="<a href='#'>添加商品</a>|<a href='#'>移出指定商品</a>|<a href='#'>清空购物车</a>|
<a href='#'>查询购物车</a>|
<a href='#'>填写订单信息</a>";
break;
case "会员":
submenu.innerHTML="<a href='#'>注册会员</a>|<a href='#'>修改会员</a>|<a href='#'>账户查询</a>";
break;
}
}
</script>
</head>
<body>
<table width="761" height="20" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="67" align="center"><a href="debug.php">首&nbsp;页</a></td>
<td width="75" align="center"><a href="#"onmousemove="lmenu('新品')">新品上架</a></td>
<td width="75" align="center"><a href="#"onmousemove="lmenu('购物')">购物车</a></td>
<td width="74" align="center"><a href="#"onmousemove="lmenu('会员')">会员中心</a></td>
<td width="61" align="center"><a href="debug.php">在线帮助</a></td>
</tr>
<tr>
<div id="submenu" class="word_yellow">&nbsp;</div>
</tr>
</table>
</body>
</html>
为什么不能显示子菜单?

解决方案 »

  1.   

    function lmenu(value){
    //加下面這行
    var submenu = document.getElementById("submenu");
      

  2.   

    submenu.innerHTML="<a href='#'>添加商品</a>|<a href='#'>移出指定商品</a>|<a href='#'>清空购物车</a>|"
    +"<a href='#'>查询购物车</a>|"
    +"<a href='#'>填写订单信息</a>";

    你要换行就把字符串连接起来
      

  3.   

    试了一下真的是字符串惹的祸,现在还有个问题就是,
    代码在表格第二行写
    <tr>
    <div id="submenu" class="word_yellow">&nbsp;</div>
    </tr>
    但是实际是子菜单在页面顶端输出,这是为什么呀?
      

  4.   

    <tr><td>
    <div id="submenu" class="word_yellow">&nbsp;</div>
    </td>
    </tr>