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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:41:17+00:00 2026-06-02T17:41:17+00:00

I am new to jQuery and looks like I need your help after not

  • 0

I am new to jQuery and looks like I need your help after not being able to get any thing from google. I have a normal accordion menu with menus (level-1) and submenus (level-2). In most cases, only the level-2 links point to a href link and the level-1 is just like a header, but in some cases, I need the level-1 link to lets say fetch some HTML content. So basically, when you click on the parent menu, it would fetch the html content and at the same time the submenu would show.

Below is my code. When I click the level-1 link, at the address bar it shows the # sign which is because in the second line of my code I have the href value assigned as a # sign. If I remove the value, then it goes to the page I want and shows the toggled menu (level-2) as well, but level-2 menu disappears quickly. Any help is appreciated. Thanks in advance.

    $(document).ready(function() {


var submenu = $(location).attr('href').substring(url.lastIndexOf('/'), url.length);

var LinkObj = $('a[href*="' + submenu + '"]').parent();
$('.mainmenunav').find(LinkObj).parent().show();


    SelLink = $('.mainmenunav').find(LinkObj).parent();


            $('.level-1 > li > a').click(function(){

                 if (SelLink != null && SelLink.html() != $(this).next().html()){
                    SelLink.slideToggle(800);
                }

                $(this).next().slideToggle(400);

                if (SelLink != null && SelLink.html() == $(this).next().html()){
                    SelLink = null;
                }else{
                    SelLink = $(this).next();
                }
            });

    });

The HTML view:

<ul id="mainmenunav">
    <li>Sport
        <ul>
            <li><a href="#">Football</a></li>
            <li><a href="#">Tennis</a></li>
        </ul>
    </li>
    <li><a href="#">News</a>
        <ul>
            <li><a href="#">Africa</a></li>
            <li><a href="#">Asia</a></li>
        </ul>
    </li>
</ul>

When I click the level-1 link, at the address bar it shows the # sign which is because in the second line of my code I have the href value assigned as a # sign. If I remove the value, then it goes to the page I want and shows the toggled menu (level-2) as well, but level-2 menu disappears quickly. Don’t get the reason.

  • 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-02T17:41:20+00:00Added an answer on June 2, 2026 at 5:41 pm

    Problem solved. Actually Liferay itself does half of the job; it just needs some tweaking and plus some jQuery as in my first post for the toggling and disabling some of the links.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to jquery and need some help. I am trying to
I'm new to jquery and trying to accomplish something. My HTML looks like: <li>
I'm very new to jQuery and I need some help: What I am looking
I'm new to jQuery and need some help to show and hide a div
For my project i need to use the jQuery Rule Plugin Its looks like
Using jQuery UI 1.8rc3 combined with the new jquery.effects.fade.js code, I've been able to
I have a document which uses old jQuery and I need new jQuery for
So since the jQuery confirm box looks awesome I figured we need to make
So, I've found similar questions about JQuery in which you do not need to
Let me start by saying I am VERY new to jQuery or any JavaScript

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.