views:

3925

answers:

3

Hi,

I am trying to make a menu that has many links and each link has its own sublist, this is what i am using..

<body>
<div id="menu">
  <a href="#"><li>users <br /></a></li>
  <a href="#"><li>product <br /></a></li>
  <a href="#"><li>movies <br /></a></li>
  <a href="#"><li>clips <br /></a></li>
  <a href="#"><li>teaser <br /></a></li>
  <a href="#"><li>trailer <br /></a></li>
  <a href="#"><li>HDMovie <br /></a></li>
</div>
</body>

my jquery..

$(document).ready(function(){
$(".users").bind("click", function(){
   $('#menu').fadeOut();
   $('#sub_menu').fadeIn();
})

This is only for the users link to show its sublist. If i want to do the same with product, movies, and clips links do I have to copy and paste the function? Can anyone here give me a example of a function so i don't have to copy paste?

Thanks ;)

A: 

Try something like this. Also, make sure your properly ending your nested tags

<body>
<ul id="products" class="menu">
<li><a href="#">users</a>
    <ul class="sub_menu'>
     <li><a href="#">user 1</a></li>
     <li><a href="#">user 1</a></li>
     <li><a href="#">user 1</a></li>
    </ul>
</li>
<li><a href="#">product</a>
    <ul class="sub_menu'>
     <li><a href="#">product 1</a></li>
     <li><a href="#">product 1</a></li>
     <li><a href="#">product 1</a></li>
    </ul>
</li>
<li><a href="#">movies</a></li>
<li><a href="#">clips</a></li>
<li><a href="#">teaser</a></li>
<li><a href="#">trailer</a></li>
<li><a href="#">HDMovie</a></li>
</ul>

</body>

the script

$(document).ready(function(){
    $(".menu > li > a").bind("click", function(){
     $('.sub_menu').fadeOut();
     $(this).parent().find('.sub_menu').fadeIn();
    }
})
bendewey
hi,thanks fo replies, i have used this function it is working it fades out my menu and also fadesIn the sub menu but the same sub menu for every link i want sub menu2 to fadeIn when i click the next link.. Thanks guys...
Here is the link what i am doing http://umarstudio.com/test/html/screen_2b.html
I just need the submenus to fade In for every link.. Thanks ;)
+1  A: 

Honestly, I would use the Superfish plugin and not reinvent the wheel. Combine it with hoverIntent and it should be able to do everything you need.

Evan
A: 

hi,

Thanks fo replie guys, i have used this function it is working it fades out my menu and also fadesIn the sub menu but the same sub menu for every link i want sub menu2 to fadeIn when i click the next link..

Here is the link what i am doing http://umarstudio.com/test/html/screen_2b.htm

I just need the submenus to fade In for every link.. Thanks ;)