Thanks Rey...
I've actually streamlined my concertina menu code now, and decided
that it wasn't actually necessary to have one event wait for the
previous one (couldn't get it to work, anyway...)
My code now works with a basic nested <ul> menu structure, with no
extra classes needed in the HTML, and will expand/close menus at any
level in the nest. The code is simple:
$('#menu li ul').prev().click(function(){
$(this).parent().siblings().children('ul:visible').slideUp('fast');
$(this).next().slideToggle('normal');
return false;
});
Line 1 locates all sub-menus within the nesting, and attaches the
event to the immediately preceding <a> element.
Line 2 steps up to the link's enclosing <li>, finds all its siblings
with a visible sub-menu, and slides them closed.
Line 3 toggles the visibility of the clicked link's sub-menu.
Line 4 stops the clicked link from being followed.
An example, with up to 3 levels of nested menus:
http://www.sebduggan.com/testing/jquery-menu.htm
I have two problems:
1. In Firefox on the Mac, on clicking a link, the toggled menu
flashes up in full for an instant, before sliding open as it should.
It works perfectly in Safari, IE Win 6+, Opera 8+, FF Win.
2. It almost works in IE 5.5, apart from the menus doing a jig to the
side when they finish opening. Is there a way to prevent IE 5.5 from
executing the jQuery scripts? (I could always do a server-side check
that doesn't write the <script> code to IE 5.5 and earlier).
Seb
On 6 Feb 2007, at 21:19, Rey Bango wrote:
> Actually Seb,
>
> Use this:
>
> $('.topMenu').click(function(){
>
> $('ul.level1:visible').slideUp('normal');
> $(this).next().slideDown('normal');
>
> return false;
>
> });
>
> Rey...
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/