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

  • Home
  • SEARCH
  • 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 1114267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:58:55+00:00 2026-05-17T02:58:55+00:00

I am a Jquery noob. I and am trying to create an accordion menu.

  • 0

I am a Jquery noob. I and am trying to create an accordion menu. I have been able to get the following js working with the following HTML code.

function initMenu() {
  $('#menu ul').hide();
  $('#menu li a').click(
    function() {
        $(this).next().slideToggle('normal');   
      }
    );
  }
$(document).ready(function() {initMenu();});

.

<li>                        
 <a href="#">Testing #1</a>
  <ul>
   <li><a href="http://www.php.net/">PHP</a></li>
   <li><a href="http://www.ruby-lang.org/en/">Ruby</a></li>
  </ul>
 </li>
 <li>
  <a href="#">Test #2</a>
   <ul>
    <li><a href="http://www.php.net/">PHP</a></li>
    <li><a href="http://www.ruby-lang.org/en/">Ruby</a></li>
  </ul>
</li>

I would like to to use table for each li. I am not sure if this is the best way. So far I have this:

<ul>
 <li>
  <table border="1">
   <tr>
    <td><a href="http://www.link1.com/">Link-1</a></td>
    <td><a href="http://www.link2.com/">Link-2</a></td>
    <td><a href="http://www.link3.com/">Link-3</a></td>
   </tr>
  </table>
 </li>

Do I need to adjust my js to work in this scenario? With the tables, it still appears to work, but I suspect I will be generating a lot more tags (Data) than needed to accomplish this.

Any helping or input is appreciated, 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-17T02:58:56+00:00Added an answer on May 17, 2026 at 2:58 am

    What you have will work, you can test it here. One suggestion though, you can shorten this:

    $(document).ready(function() {initMenu();});​
    

    Down to:

    $(initMenu);​
    

    When passing a function to $() it attaches that function as a document.ready handler, and it’ll execute when the page is good to go.
    You can test that here, or the anonymous function version like this:

    $(function () {
      $('#menu ul').hide();
      $('#menu li a').click(function() {
        $(this).next().slideToggle('normal');    
      });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a js/jquery noob and have been struggling to get an anonymous function to
I'm a noob in jQuery and have stuck at this. I have the following
I'm a noob at json (know a bit of jquery)....and trying to get a
im trying to create an autosuggestion feature in jquery(just experimental- jquery noob), im using
jQuery noob here: I have the following message div that shows a message on
Noob here learning backbone.js. I was trying to create a simple horizontal menu (each
I am a complete jQuery and Javascript noob trying to get a very simple
I am a jQuery noob and seems I always will be, been trying to
Greetings from some noob trying to learn JQuery, I am attempting to make it
I'm a complete noob to jquery and jquery ui but have successfully implemented a

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.