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 12-08-2011, 10:37 AM   PM User | #1
samz
New Coder

 
Join Date: Sep 2011
Location: UK, South Wales, Newport
Posts: 21
Thanks: 8
Thanked 0 Times in 0 Posts
samz is an unknown quantity at this point
Hide sub-menu when not focused

The Code
Basic nav bar made from a table in html. When the menu item "cakes" is hovered i want a dropdown list called "sub-links" to appear. Which it does.

The Question
I wana keep the dropdown list shown when its focused, but as soon as it looses focus i want it to hide.

Code:
	//Toggle sub-menu
	$('.sub-links').hide();
	$('.NavBar').find('#cakes').hover(function(){
		$('.sub-links').show();
		//if the sub menu has focus then show it, if not then hide it
	if($('sub-links').focus=false){
		$(this).hide();
	}
	});
Thank You

Last edited by samz; 12-08-2011 at 11:02 AM..
samz is offline   Reply With Quote
Old 12-08-2011, 09:22 PM   PM User | #2
harbingerOTV
Senior Coder

 
Join Date: Jan 2005
Location: Memphis, TN
Posts: 1,765
Thanks: 8
Thanked 123 Times in 121 Posts
harbingerOTV will become famous soon enough
you want something like this?

Code:
	$('.sub-links').hide();
	$('.NavBar #cakes, .sub-links').hover(function(){
		$('.sub-links').show();
	}, function(){
		$('.sub-links').hide();
	});
__________________
Stop making things so hard on yourself.
i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis
harbingerOTV is offline   Reply With Quote
Users who have thanked harbingerOTV for this post:
samz (12-09-2011)
Old 12-09-2011, 02:06 AM   PM User | #3
samz
New Coder

 
Join Date: Sep 2011
Location: UK, South Wales, Newport
Posts: 21
Thanks: 8
Thanked 0 Times in 0 Posts
samz is an unknown quantity at this point
thats exactly what i wanted...buuuutttt.....its sorta glitchy.

once "cakes" is highlighted and the dropdown menu is shown, you have to quickly move the mouse onto the dropdown otherwise it will hide.

Is ther a way to add a delay to the hide bit? should i even consider that method?

Last edited by samz; 12-09-2011 at 02:18 AM..
samz is offline   Reply With Quote
Old 12-09-2011, 02:27 AM   PM User | #4
samz
New Coder

 
Join Date: Sep 2011
Location: UK, South Wales, Newport
Posts: 21
Thanks: 8
Thanked 0 Times in 0 Posts
samz is an unknown quantity at this point
0o0o0 i did it....i just moved the dropdown table a lil closer to the NavBar.
And now i can slowly move onto the dropdown menu before it vanishes.

Did you have a better idea in mind tho? My method seems a bit...childish/unproffesional lol

Last edited by samz; 12-09-2011 at 02:32 AM..
samz 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 11:04 AM.


Advertisement
Log in to turn off these ads.