Reputation: 2966
Having some issues with my dropdown menu. Code here: http://jsfiddle.net/xY2p6/1/
Something simple I'm just not getting, but as you can see it's not functioning correctly. I'm not sure how to link the hiding of the dropdown to when the user hovers off of the menu link, rather than the actual dropdown.
Any ideas?
Upvotes: 2
Views: 2175
Reputation: 57278
Your javascript is slighty messed up.
$(document).ready(function() {
$(".dropdown").hover(
function(){
$(this).children("div.sub-menu").slideDown(200);
},
function(){
$(this).children("div.sub-menu").slideUp(200);
}
);
});
here you go: http://jsfiddle.net/xY2p6/4/
Upvotes: 3
Reputation: 630627
Since your menu is inside the same <li>
you can just attach the hover to it directly, like this:
$(function() {
$(".dropdown").hover(function() {
$(this).children("div.sub-menu").slideDown(200);
}, function() {
$(this).children("div.sub-menu").slideUp(200);
});
});
You can give it a try here, or even simpler with .slideToggle()
, like this:
$(function() {
$(".dropdown").hover(function() {
$(this).children("div.sub-menu").slideToggle(200);
});
});
Upvotes: 3