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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:22:52+00:00 2026-05-30T09:22:52+00:00

I am using PHP to echo my list of navigation options, this is being

  • 0

I am using PHP to echo my list of navigation options, this is being done due to different privileges for each user. The list is divided into groups which has a few more list items, one a user clicks on the heading of the group expands, listing the sub-menu. I have been able to set the active class for the menu which is currently open using this piece of javascript:

function initMenu() {
    $('#menu ul').hide();
    $('#menu li a').click(function() {
        var checkElement = $(this).next();
        if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        //slide up if visible (works fine).
        }
        if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        //otherwise slideDown (works fine too).
        }
    });
}

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

function markActiveLink() {
   $("#menu li ul li a").filter(function() {
       return $(this).prop("href").toUpperCase() == window.location.href.toUpperCase();
   }).addClass("active")
   .closest('ul') //some markup problem
   .slideDown('normal');
}

And this is my markup for list that are being displayed:

echo "<ul id='menu'>";
 echo "<li><a href='#'>Adminstration</a>
<ul><li>";
echo "<a href='path_to_page/usermanagement.php'>User Management</a>";
echo "</li><li>";
// and some more items

Here administration is my group heading and User Management is my sub-group.
Now using the above piece of code i am still not able to expand my menu on different pages, so that the user knows which page he is on?

  • 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-30T09:22:54+00:00Added an answer on May 30, 2026 at 9:22 am

    I figured out the problem, for some odd reason, it requires me to declare the variable first:

     var checkEle = $("#menu li ul li a").filter(function() {
           return $(this).prop("href").toUpperCase() == window.location.href.toUpperCase();
       }).addClass("active")
       .closest('ul');   //get the closest ul 
       console.log(checkEle);
       checkEle.slideDown('normal');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using php to do this: while ($row = mysql_fetch_object($db_list)) { echo $row->Database .
I'm using PHP to echo a content stored on my database. The content is
I'm using CodeIgniter (because it's awesome) and I have something like: <?php echo anchor(/,
Using PHP, what's the fastest way to convert a string like this: 123 to
Basically, I have populated a dropdown list using php from a database on a
I'm writing a simple linear linked list implementation in PHP. This is basically just
I am using this code to have a simple gallery on the page: <?php
Using PHP I am retrieving a list of videos. I am using jquery to
I'm presented with a problem using PHP and MYSQL. I have a dynamic list
Here is the script as I am using it now: <?php echo '<html><body>'; //

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.