HTML (the list)
We are going to have our unordered list in a container with its ID as 'menu'. I have also included the jQuery code inside <h3>. Notice the .slideToggle() function. This piece of code will handle the show/hide feature for your unordered list with ID 'mylist'.
- <div id="menu">
- <h3 onclick="javascript: $('#mylist').slideToggle('slow');">Click to toggle</h3>
- <ul id="mylist">
- <li><a href="#">my sample link #1</a></li>
- <li><a href="#">my sample link #2</a></li>
- <li><a href="#">my sample link #3</a></li>
- </ul>
- </div>
The CSS
You can always edit the css code so that it matches your site's colour scheme.
- #menu {
- width: 200px;
- border: 1px solid #ccc;
- padding: 0px;
- margin: 0px;
- }
- #menu h3 {
- height: 30px;
- font-weight: normal;
- background-color: #555;
- color: #fff;
- padding: 3px 0px 0px 3px;
- margin: 0px;
- }
- #menu ul, #menu ul li {
- padding: 3px;
- margin: 0px;
- list-style: none;
- }
- #menu ul li {
- height: 30px;
- vertical-align: middle;
- }
- #menu ul li a {
- display: block;
- border-bottom: 1px dashed #eee;
- text-decoration: none;
- font-weight: bold;
- }
Dont forget to add the jQuery javascript file inside the HEAD tag of you web page. The toggle effect wont work without this library.
Have fun!













