多级菜单
2016-07-13 19:21
211 查看
<!DOCTYPE html>
<html>
<head>
<meta
charset="UTF-8">
<title></title>
<style
type="text/css">
*
{
margin:
0;
padding:
0;
}
#ul1
{
position:
absolute;
display:
none;
}
ul
{
list-style:
none;
}
li
{
background-color: paleturquoise;
color: deeppink;
width:
100px;
text-align: center;
position:
relative;
font-size:
12px;
}
li>ul
{
width:
100px;
position:
absolute;
left:
98px;
top:
-2px;
display:
none;
}
</style>
</head>
<body>
<ul
id="ul1">
<li>我是li1</li>
<li>我是li2</li>
<li>我是li3
<ul>
<li>我是li3下的li1</li>
<li>我是li3下的li2</li>
<li>我是li3下的li3</li>
</ul>
</li>
<li>我是li4
<ul>
<li>我是li4下的li1</li>
<li>我是li4下的li2
<ul>
<li>我是li4下的li2下的li1</li>
<li>我是li4下的li2下的li2</li>
<li>我是li4下的li2下的li3</li>
</ul>
</li>
<li>我是li4下的li3</li>
</ul>
</li>
<li>我是li5</li>
</ul>
<script
type="text/javascript">
var
ul1 = document.getElementById("ul1");
var
lis = document.getElementsByTagName("li");
document.oncontextmenu
= function() {
ul1.style.display
= "block";
var
x = event.clientX;
var
y = event.clientY;
ul1.style.left
= x + "px";
ul1.style.top
= y + "px";
return
false;
}
document.onclick
= function() {
ul1.style.display
= "none";
}
for
(var i = 0; i
< lis.length; i++) {
lis[i].onmouseover
= function(){
var
child = this.children;
// li有孩子节点
if
(child.length > 0) {
// 过滤其他标签
if
(child[0].nodeName == "UL") {
child[0].style.display
= "block";
}
}
}
lis[i].onmouseout
= function(){
var
child = this.children;
// li有孩子节点
if
(child.length > 0) {
// 过滤其他标签
if
(child[0].nodeName == "UL") {
child[0].style.display
= "none";
}
}
}
}
</script>
</body>
</html>
<html>
<head>
<meta
charset="UTF-8">
<title></title>
<style
type="text/css">
*
{
margin:
0;
padding:
0;
}
#ul1
{
position:
absolute;
display:
none;
}
ul
{
list-style:
none;
}
li
{
background-color: paleturquoise;
color: deeppink;
width:
100px;
text-align: center;
position:
relative;
font-size:
12px;
}
li>ul
{
width:
100px;
position:
absolute;
left:
98px;
top:
-2px;
display:
none;
}
</style>
</head>
<body>
<ul
id="ul1">
<li>我是li1</li>
<li>我是li2</li>
<li>我是li3
<ul>
<li>我是li3下的li1</li>
<li>我是li3下的li2</li>
<li>我是li3下的li3</li>
</ul>
</li>
<li>我是li4
<ul>
<li>我是li4下的li1</li>
<li>我是li4下的li2
<ul>
<li>我是li4下的li2下的li1</li>
<li>我是li4下的li2下的li2</li>
<li>我是li4下的li2下的li3</li>
</ul>
</li>
<li>我是li4下的li3</li>
</ul>
</li>
<li>我是li5</li>
</ul>
<script
type="text/javascript">
var
ul1 = document.getElementById("ul1");
var
lis = document.getElementsByTagName("li");
document.oncontextmenu
= function() {
ul1.style.display
= "block";
var
x = event.clientX;
var
y = event.clientY;
ul1.style.left
= x + "px";
ul1.style.top
= y + "px";
return
false;
}
document.onclick
= function() {
ul1.style.display
= "none";
}
for
(var i = 0; i
< lis.length; i++) {
lis[i].onmouseover
= function(){
var
child = this.children;
// li有孩子节点
if
(child.length > 0) {
// 过滤其他标签
if
(child[0].nodeName == "UL") {
child[0].style.display
= "block";
}
}
}
lis[i].onmouseout
= function(){
var
child = this.children;
// li有孩子节点
if
(child.length > 0) {
// 过滤其他标签
if
(child[0].nodeName == "UL") {
child[0].style.display
= "none";
}
}
}
}
</script>
</body>
</html>
相关文章推荐
- jQuery插件实现多级联动菜单效果
- Shell实现多级菜单系统安装维护脚本实例分享
- 下拉多级菜单
- bootstrap2 多级下拉菜单
- 安卓实现多下拉筛选多条件筛选菜单多级筛选菜单
- 使用java 和freemarker实现多级菜单(分类)
- JavaScript小练习效果之多级菜单
- django 文件上传和菜单分级,mysql支持事务,F模块自增字段, python发送get,post请求
- python 多级菜单进入城市
- 纯css实现多级折叠菜单,折叠树
- 使用vue开发多级多选菜单组件
- JS巧妙实现多级菜单中当前菜单不随页面跳转样式而发生变化
- 多级菜单-事件委托
- 多级菜单框架(C实现)
- Android 多级菜单联动操作
- iOS 多级菜单控件
- Jeecg使用多级菜单
- JS实现多级菜单中当前菜单不随页面跳转样式而发生变化
- Bootstrap多级菜单的实现代码
- 快速实现jQuery多级菜单效果