<script type="text/javascript">
function shownav()
{
var nav=document.getElementById('nav').getElementsByTagName("li");
for(i=0;i<nav.length;i++)
{
nav[i].onmouseover=function()
{
nav[i].childNodes[i].style.display="none";
}
nav[i].onmouseout=function()
{
}
}
}
</script>
</head>
<body onload="shownav()">
<ul id="nav">
<li>About
<ul>
<li>Introduction</li>
<li>means</li>
<li>Features</li>
</ul>
</li>
<li>About
<ul>
<li>Introduction</li>
<li>means</li>
<li>Features</li>
</ul>
</li>
</ul>
</body>
</html>
------解决方案--------------------
- HTML code
<style> ul ul {display:none} </style> <script type="text/javascript"> function shownav() { var nav=document.getElementById('nav').children; for(i=0,len=nav.length;i<len;i++) { nav[i].onmouseover=function() { this.children[0].style.display="block"; } nav[i].onmouseout=function() { this.children[0].style.display="none"; } } } </script> </head> <body onload="shownav()"> <ul id="nav"> <li>About <ul> <li>Introduction</li> <li>means</li> <li>Features</li> </ul> </li> <li>About <ul> <li>Introduction</li> <li>means</li> <li>Features</li> </ul> </li> </ul> </body> </html>