慕粉3770264
2016-09-28 13:43
<style>
li{ list-style:none; }
ul{ padding:0;margin:0;}
.lis{ position:relative; list-style:none; width:80px; height:30px; border:1px solid #000;}
.lis a{ text-decoration:none; display:block; line-height:30px; text-align:center;}
ul ul{ display:none; padding:0;margin:0; position:absolute; top:30px; left:-1px;border:1px solid #000; width:140px;}
ul ul li{ text-align:center;line-height:30px;}
</style>
<script>
document.getElementById('lis').onmouseover = show;
document.getElementById('lis').onmouseout = hide;
function show(){
document.getElementById('ul1').style.display='block';
}
function hide(){
document.getElementById('ul1').style.display='none';
}
</script>
</head>
<body>
<ul>
<li class="lis"><a href="#" id="link">微博</a>
<ul id="ul1">
<li>死心</li>
<li>死心</li>
<li>死心</li>
</ul>
</li>
</ul>
</body>
≧∇≦ 小白好像看出来了,你给元素绑定事件调用函数时的格式有点小问题,这样改试试:
document.getElementById('lis').onmouseover = function(){show();}
document.getElementById('lis').onmouseout = function(){hide();}
JS动画效果
113925 学习 · 1443 问题
相似问题