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-20-2010, 12:23 PM   PM User | #1
Skullzy
New Coder

 
Join Date: Dec 2010
Location: Northern Ireland, Belfast
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Skullzy is an unknown quantity at this point
Jquery dropdownmenu

I've created a simple dropdown menu using jquery.

here is the HTML
Code:
<div id="button">
<div style="background:url(images/button1.png); width: 184px; height: 32px;" class="menu_class"></div>
<ul class="the_menu" tabindex="1">
<li><a href="#" name="website1">A Website #1</a></li>
<li><a href="#" name="website2">A Website #2</a></li>
<li><a href="#" name="website3">A Link #1</a></li>
<li><a href="#" name="website4">A Link #2</a></li>
<li><a href="#" name="website5">A Website #3</a></li>
<li><a href="#" name="website6">A Website #4</a></li>
<li><a href="#" name="website7">A Link #3</a></li>
<li><a href="#" name="website8">A Link #4</a></li>
</ul>
</div>
Here is the jquery bit
Code:
$(document).ready(function () {
    $('div.menu_class').click(function () {
		$('ul.the_menu').slideToggle('medium');
	});
	$('a').click( function() {
		var VALUE = $(this).attr('name');
		$('div.menu_class').html(VALUE);
		$('ul.the_menu').slideToggle('medium');
	});
	$('#button').blur( function() {
		$('ul.the_menu').slideToggle('medium');
	});
});
What am trying to do is on click of the (a) for it to display the selected link in the menu_class now this works but what am having issue's with is that i want to also beable to close the menu down on blur or onmouseout.

I attempted the on mouseout and didn't work well it kept closing it down when i went to hover over one of the menu links

but onblur works perfectly if i click off the menu but the issue is that i cant use the fallowing two codes together

Code:
        $('a').click( function() {
		var VALUE = $(this).attr('name');
		$('div.menu_class').html(VALUE);
		$('ul.the_menu').slideToggle('medium');
	});
	$('#button').blur( function() {
		$('ul.the_menu').slideToggle('medium');
	});
if i remove the blur one it will make the text for what ever link i click show in the menu_class part but if i add the blur it wont display the selected link am not sure how to fix this but i hope someone can help.

thank you in advance
Skullzy 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 08:41 AM.


Advertisement
Log in to turn off these ads.