Basically I created a dropdown menu with jquery by using the slideUp and slideDown functions. Everything worked good until I figured that if I continue hovering the mouse through the list, the height of the sub button won't stop. And we can see that by the border-left expanding. Any way to avoid this?
I've created a fiddle so that you guys can know what I'm talking about http://jsfiddle.net/WGm8q/
Anyway here's the code:
JS
$('.button').hover(
function () {
$('.sub', this).stop().slideDown(100);
},
function () {
$('.sub', this).stop().slideUp(100);
}
);
CSS
.menu {
width: 850px;
}
.button .main {
padding-bottom: 5px;
cursor: pointer;
}
.button .sub {
display: none;
margin-left: 10px;
padding: 10px 0 10px 0;
border-left: 1px solid #CCC;
}
.button .sub p {
background-color: #FFF;
margin: 0;
padding-left: 5px;
}
HTML
<div class="menu">
<div class="button">
<div class="main">Menu 1</div>
<div class="sub">
<p>Submenu 1</p>
<p>Submenu 1</p>
<p>Submenu 1</p>
<p>Submenu 1</p>
<p>Submenu 1</p>
<p>Submenu 1</p>
<p>Submenu 1</p>
</div>
</div>
</div>