Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-11-2013, 07:54 PM   PM User | #1
Chrys
New Coder

 
Join Date: Aug 2011
Posts: 43
Thanks: 12
Thanked 0 Times in 0 Posts
Chrys is an unknown quantity at this point
jQuery navigation hiding before I can click menu items

I have a very simple navigation where I am using jquery to hide and show submenues on mouseover and hide them on mouseleave. When you hover over the main navigation it shows like it should but when you try to move your mouse down to click on the submenu items they hide. UGH!! Im not sure what to do about this.

I know from trial and error that it the speed that is killing it for me. When I remove the 400 it works fine but I that shouldn't affect the code that it is. Even if I add "slide inside the show function it still acts funny."
Does anyone have any ideas?

Code:
function nav(){
$('div#nav ul li').mouseover(function() {
$(this).find('ul').show(400);
});

$('div#nav ul li').mouseleave(function() {
$('div#nav ul li ul').hide();
});

$('div#nav ul li ul').mouseleave(function() {
$('div#nav ul li ul').hide();;
});
};

$(document).ready(function() {nav();});

Last edited by Chrys; 02-11-2013 at 08:11 PM..
Chrys is offline   Reply With Quote
Old 02-13-2013, 02:32 PM   PM User | #2
Chrys
New Coder

 
Join Date: Aug 2011
Posts: 43
Thanks: 12
Thanked 0 Times in 0 Posts
Chrys is an unknown quantity at this point
Does anyone have any ideas why the animation wont work?
Chrys is offline   Reply With Quote
Old 02-13-2013, 03:12 PM   PM User | #3
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,604
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Without further looking into it I notice a syntax error:
Code:
$('div#nav ul li ul').hide();;
There is one semicolon too much.

For everything else we need to see more of your site – a link to a live example would be good. Alternatively there are sites like http://jsbin.com/, for example, where you can test your code and show it to others.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Users who have thanked VIPStephan for this post:
Chrys (02-13-2013)
Old 02-13-2013, 04:34 PM   PM User | #4
Chrys
New Coder

 
Join Date: Aug 2011
Posts: 43
Thanks: 12
Thanked 0 Times in 0 Posts
Chrys is an unknown quantity at this point
SIMPLE sliding jquery navigation-works great now!

I figured it out. I was trying to be too specific with the hide script and I was hiding my menu when I was leaving particular elements within the list item. LOL! This is my script and it works well now. I also added in the click to toggle part because when you are on a mobile device the menu wont hide because there is no mouseleave. :-)

Code:
function nav(){
$('div#nav ul li').mouseover(function() {
$(this).find('ul').show("fast");
});

$('div#nav ul li').mouseleave(function() {
$(this).find('ul').hide("fast");
});

$('div#nav ul li').click(function() {
$(this).find('ul').toggle("fast");
});
};
Chrys is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:37 AM.


Advertisement
Log in to turn off these ads.