Hello guys,
i'm trying to code an accordion menu with categories for a website!
Here the HTML:
Code HTML4Strict:<div id="accordion_prodotti"> <ul id="accordion"> <li><a href="#">Menu 1</a></li> <li><a href="#">Menu 2</a></li> <li><a href="#">Menu 3</a> <ul> <li><a href="#">Item 1</a></li> <li><a href="#">Item 2</a></li> <li><a href="#">Item 3</a></li> <li><a href="#">Item 4</a></li> </ul> </li> <li><a href="#">Menu 4</a> <ul> <li><a href="#">Item 1</a></li> <li><a href="#">Item 2</a></li> </ul> </li> <li><a href="#">Menu 5</a> <ul> <li><a href="#">Item 1</a></li> <li><a href="#">Item 2</a></li> <li><a href="#">Item 3</a></li> </ul> </li> </ul> </div>
Here the jQuery Code:
Code JavaScript:// Accordion $('#accordion li').click(function() { if ($('ul', this).is(':visible')) { // Nascondi sottoMenu $("ul", this).stop(true, true).slideUp(200); } else { // Mostra sottoMenu $("ul", this).stop(true, true).delay(50).slideDown(100); } });
Ok, this is what i wrote in my page but the problem is:
When i click on a "Menu", the "Item" should SlideDown and when i click back on the same "Menu" it should SlideUp! this works correctly, but what, if i click on a "Item" instead of a "Menu"?! The clicked "Menu" SlideUp! What's wrong with it? I just want to SlideUp/Down when i click on a "Menu" and not when i click on a "Item"!
I have to say that i'm not a good coder in jQuery and probably i missed some classes to do it! but i would like to learn it aswell, reading some books and tutorials!
Any ideas, tips? I'd appreciate it! Thank you..


Reply With Quote




Bookmarks