满意答案
yj19791212
.04.21
采纳率:59%等级:12
已帮助:7421人
下面是最基本的框架,内容和样式你需要自己调整
#tree {
width: 150px;
}
#tree, #tree ul {
list-style: none; margin: 0; padding: 0; padding: 10px;
}
#tree li {
border: 1px solid #00f; padding: 10px; cursor: pointer;
}
#tree ul {
display: none;
}
window.onload = function() {
var tree = document.getElementById("tree");
var lis = tree.getElementsByTagName("li");
for(var i = 0; i < lis.length; i++) {
(function(a) {
lis[a].onclick = function() {
if(typeof this.getElementsByTagName("ul") !== null) {
var ul_first = this.getElementsByTagName("ul")[0];
if(ul_first.style.display == "block")
ul_first.style.display = "none";
else
ul_first.style.display = "block";
}
};
})(i);
}
};
菜单一1-11-21-31-4菜单二2-12-22-32-4菜单三3-13-23-33-4
00分享举报