动态级联菜单怎么实现的?

来源:百度知道 编辑:UC知道 时间:2024/05/10 10:00:51
怎么实现点击一级菜单,可以显示二级菜单.再点击一级菜单,就可以隐二级菜单.谢谢,请具体点.
一级菜单和二级菜单都从数据库中读取,怎么实现?

方法1: 用Css实现
<html>
<head>
<title>css菜单显示效果</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
/**
*菜单的构造,需要绑定到onload
*/
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList