Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6213103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:38:12+00:00 2026-05-24T06:38:12+00:00

I am still fairly new to jQuery so the following may seem pretty basic

  • 0

I am still fairly new to jQuery so the following may seem pretty basic to many of you.

I am working on an accordion navigation that uses jQuery (but I am not using jQuery UI). The page is here: http://www.rouviere.com/nav/index.html

Here is the HTML:

<div id="subContent">
<ul>
<li><a href="nikon.html">Nikon</a></li>

<li class="cameras"><a href="#" class="drop">Cameras</a>
<ul>
<li><a href="nikon-d3x.html">Nikon D3x</a></li>
<li><a href="nikon-d3s.html">Nikon D3s</a></li>
<li><a href="nikon-d700.html">Nikon D700</a></li>
<li><a href="nikon-d300s.html">Nikon D300s</a></li>      
</ul>
</li>

<li class="lenses"><a href="#" class="drop">Lenses</a>
<ul>
<li><a href="24-70.html">Nikkor 24-70 f2.8</a></li>
<li><a href="80-200.aspx">Nikkor 80-200 f2.8</a></li> 
<li><a href="300.html">Nikkor 300 f2.8</a></li>
<li><a href="50.html">Nikkor 50 f1.4</a></li>
</ul>
</li>

<li class="bags"><a href="#" class="drop">Bags</a>
<ul>
<li><a  href="bag1.html">Small Bag</a></li>
<li><a href="bag2.html">Medium Bag</a></li>
<li><a href="bag3.html">Large Ba</a></li>
</ul>
</li> 
<li><a href="#" class="drop">Memory Cards</a></li>
</ul>
</div>

Here is the jQuery:

<script type="text/javascript">
$(function(){
    $('.interior #subContent > ul > li > a.drop').click(function(){
    $(this).parent().children('ul').toggle("slow");
         return false;
    });

    $(window).ready(function() {
        $('li.cameras ul').hide();
        $('li.lenses ul').hide();
        $('li.bags ul').hide();
    }); 
}); 
</script>

The page displays with the ul li ul all collapsed, however, they don’t toggle open when you click on the parent links.

I would appreciate a seasoned eye or two to review this and help me figure out what is missing.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:38:13+00:00Added an answer on May 24, 2026 at 6:38 am

    Shorter way to write it:

    $(function() {
        $('#subContent > ul > li')
            .children('a.drop').click(function() {
                $(this).siblings('ul').toggle("slow");
                return false;
            }).end()
            .children('ul').hide();
    }); 
    

    $(window).ready() is meaningless. I’m suprised it did anything before.

    A more meaningful and expandable way to write it would probably be this:

    $(function() {
        $('#subContent > ul > li').each(function() {
            var toggler = $(this).children('a.drop');
            var sublist = $(this).children('ul');
    
            toggler.click(function() {
                sublist.toggle("slow");
                return false;
            });
            sublist.hide();
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I fairly new to JQuery and perhaps trying to achieve something that might be
I'm fairly new to jQuery still and am trying to pick up ways to
I've written a fairly basic jQuery plugin that takes an unordered list and creates
Im still fairly new to Django, so please explain things with that in mind.
I'm still fairly new to T-SQL and SQL 2005. I need to import a
I'm still fairly new to ASP.NET development so bear with me. I'm going to
I'm still a newbie to Adobe Air/Flex, and still fairly new with SQL. I've
Still new to Objective C, and I'm having some trouble that I just can't
I still very new using Subversion. Is it possible to have a working copy
I'm playing around with writing a jQuery plugin that uses an attribute to define

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.