PDA

View Full Version : jQuery Accordian as menu problem



monkey
12-02-2011, 01:17 PM
Hey guys,

I'm new here and I've just finished my website. I got some usage feedback and a problem with my jquery accordian menu has come up. I'd like to caution I'm really amateur, not a web coder at all - I'm a graphic designer for identity and print, but I've some how over 7/8 months managed to build my site - http://www.asheck.com/ to what it is now. its not perfect but I'm working on the issues...

I have with my accordian menu so if we click on items, it drops down and we if we click another menu item it closes the previous item and opens the new one which is fine. The problem is which people have found annoying is, if you click a menu item and then click the SAME one again, it collapses then springs opens again... instead of just closing - is there a way to fix this?

The code that codes this is as follows...


jQuery(document).ready(function(){
jQuery( '#menu > li > ul' ).hide()
jQuery('#menu > li').addClass('inactive');

jQuery('#menu > li').click(function(e){
jQuery('#menu > li > ul').slideUp();
jQuery('#menu > li').addClass('inactive');
jQuery('ul',this).slideDown();
jQuery(this).removeClass('inactive');
}, function(){
jQuery( this ).parent().find('ul').slideUp();
});
});


Any help would be appreciated, its been driving me nuts trying to get this sorted I only just managed to have it so that menu's collapse when another item gets clicked...

Cheers.

ggalan
12-02-2011, 11:31 PM
did you want the slide up to not happen? how about just commenting out this


jQuery(document).ready(function(){
jQuery( '#menu > li > ul' ).hide()
jQuery('#menu > li').addClass('inactive');

jQuery('#menu > li').click(function(e){
//jQuery('#menu > li > ul').slideUp();
jQuery('#menu > li').addClass('inactive');
jQuery('ul',this).slideDown();
jQuery(this).removeClass('inactive');
}, function(){
jQuery( this ).parent().find('ul').slideUp();
});
});

monkey
12-03-2011, 01:52 PM
^thanks for the response, but I've managed to solve it with the help of a friend - you can see now what I mean in terms of how I wanted it. now I just need to solve the ie7 and 8 issues...lol...