<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>导航栏作业</title>
<style>
*{margin: 0;padding: 0;border: 0;list-style: none;}
ul{width: 340px;height: 30px;background: url(./images/bg.jpg) no-repeat;margin: 100px auto;}
ul>li{margin-left: 10px;float: left;}
span, ol li{background: url(./images/libg.jpg) no-repeat;width: 100px;height: 30px;display: block;text-align: center;line-height: 30px;cursor: pointer;}
ol{display: none;}
</style>
</head>
<body>
<ul>
<li>
<span>一级菜单</span>
<ol>
<li>二级菜单</li>
<li>二级菜单</li>
<li>二级菜单</li>
</ol>
</li>
<li>
<span>一级菜单</span>
<ol>
<li>二级菜单</li>
<li>二级菜单</li>
<li>二级菜单</li>
</ol>
</li>
<li>
<span>一级菜单</span>
<ol>
<li>二级菜单</li>
<li>二级菜单</li>
<li>二级菜单</li>
</ol>
</li>
</ul>
<script src="./js/jquery-1.12.4.min.js"></script>
<script>
$("ul>li").hover(function(){
// ol的移入显示移出隐藏
// $(this).children("ol").toggle();
$(this).children("ol").stop().slideToggle();
})
</script>
</body>
</html>