0

I have this menu:

      <div id="menu">
            <div class="header">Menu Header</div>
            <ul>
                <li>asdfsadfdsaf</li>
                <li>sadfsadf</li>
                <li>asdfasdf</li>
                <li>asdfsadf</li>
                <li>asdfsadf</li>
            </ul> 
         </div>

How can I do, so whenever I click on one of the links inside each LI, a new sub-menu will toggle in "under" the clicked one?

1
  • Have you looked at the jquery click event handler? One of the easiest ways would be to have attach a click event listener to each of the li's and have it show or hide another set of ul/li elements that are contained in the current one. This requries a bit of css work as well. What have you tried? Commented Sep 8, 2011 at 21:00

2 Answers 2

1

Here is a simple menu pattern to follow:

http://jsfiddle.net/Diodeus/jejNy/

Sign up to request clarification or add additional context in comments.

1 Comment

He wrote "click", so you could just replace mouseenter with a click :D
0

First, you need different markup:

<div id="menu">
    <div class="header">Menu Header</div>
    <ul>
        <li>
            <span>Menu item</span>
            <ul>
                <li>Submenu item</li>
                <li>Submenu item</li>
                <li>Submenu item</li>
            </ul>
        </li>
        <li>
            <span>Menu item</span>
            <ul>
                <li>Submenu item</li>
                <li>Submenu item</li>
                <li>Submenu item</li>
            </ul>
        </li>
        ...
    </ul> 
</div>

And simply apply the css and js to the submenu, just like u did with the mainmenu

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.