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 8115971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:39:33+00:00 2026-06-06T03:39:33+00:00

I found a tutorial on css tricks to make a simple accordion. http://css-tricks.com/snippets/jquery/simple-jquery-accordion/ I

  • 0

I found a tutorial on css tricks to make a simple accordion.

http://css-tricks.com/snippets/jquery/simple-jquery-accordion/

I noticed this is not really based on a navigation, but I could see how it was working so I made some simple adjustments to make it work with a un-ordered list navigation menu. But at the time, even though I got the animation to run sweet, I did not realize this would disrupt the actual anchor click events.

var allPanels = $('.sub-menu').hide();

$('li.menu-item a').click(function() {
    allPanels.slideUp();
    $(this).parent().find('ul').slideDown();
    return false;
});

Please see jsfiddle I have created to demonstrate issue.

http://jsfiddle.net/Yj4px/2/

As you can see all the links are dead, and the just activate the script.

I would really appreciate any pointers please as I’m stuggling with this one. I would really like to avoid a jquery plugin at all costs. Thanks in advance.


At a guess, the script only needs to run li.menu-item contains a ul – I cannot add classes as the menu will be dynamically generated by a cms, and could change at anytime. So script needs to run by itself.

  • 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-06-06T03:39:34+00:00Added an answer on June 6, 2026 at 3:39 am

    You need to return false only if the <a> tag is not a direct link or browser will still want to go back to top of page

    Change href of accordion headers that have panels to “#”. Redirect links will work normally with following “IF”, accordion will work normally alos

    $('li.menu-item a').click(function() {
        if($(this).attr('href')=="#"){
            allPanels.slideUp();
            $(this).parent().find('ul').slideDown();
            return false;
        }
    });
    

    In your server code add a class “active” to link within panel that needs opening ( match the href to the url)
    On page load

    $('a.active').closest('ul').slideDown()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this tutorial which pretty much does exactly what I want: http://webstutorial.com/jquery-popup-jquery-slide-popup/jquery Except
I'm running through this tutorial found here: http://vb.net-informations.com/crystal-report/vb.net_crystal_report_from_multiple_tables.htm which teaches how to pass a
I'm following this tutorial and am trying to modify it to my use: http://net.tutsplus.com/tutorials/html-css-techniques/how-to-build-a-kick-butt-css3-mega-drop-down-menu/
I was reading this tutorial from the DNN website http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryId/2675/DotNetNuke-Skinning-101-Part-2.aspx I found the tutorial
I am trying to imitate this tutorial about creating a simple Apple-themed breadcrumb found
I have currently implemented this image slider http://www.dreamcss.com/2009/04/create-beautiful-jquery-sliders.html on a site but for some
I want to make a nice, modern-looking transitions between pages. I've found this tutorial:
I found This tutorial for resize background of button . i change this for
I found this JSF tutorial which shows how to create JSF table with pagination
How do I use regular expressions in CSS? I found a tutorial here for

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.