<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> Learn how to make a navigation bar </title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function() {
$(".div1").click(function() {
$(".div2").addClass("dlHover");
});
$(".div1").hover(function(){//The first function is the one that executes when the mouse hovers
$(this).addClass("bg");
},function(){//The second function ACTS as a function that is executed when the mouse is away
$(this).removeClass("bg");
$(".div2").removeClass("dlHover");
});
});
</script>
<style>
*{margin: 0px auto;padding: 0px;text-align: center;}
ul{list-style: none;}
.div2{display:none;width: 100px;border: 1px solid gray;background: #00FFFF;}
.dlHover{position:absolute;z-index: 9999;display: block;}
.div1{border: 1px solid gray;width: 100px;background-color: #999999;}
.bg{background-color: #1F9999;}
</style>
</head>
<body>
<div class="div1">
<span class="span1"> navigation 1</span>
<div class="div2">
<ul>
<li><a href="#"> navigation 2</a></li>
<li><a href="#"> navigation 3</a></li>
</ul>
</div>
</div>
<h3> Learn how to make a navigation bar </h3>
<p> This is a simple navigation bar </p>
</body>
</html>