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

The Archive Base Latest Questions

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

I have a path like this: http://www.domain.com/admin/item.php?id=4&action=edit And want to get that path, compare

  • 0

I have a path like this:

http://www.domain.com/admin/item.php?id=4&action=edit

And want to get that path, compare with every element of my menu, and add the class “active” to the current menu item, like this:

<ul class="nav nav-list">
<li><a href="http://www.domain.com/admin/item.php?id=1&action=edit">Item 1</a></li>
<li><a href="http://www.domain.com/admin/item.php?id=2&action=edit">Item 2</a></li>
<li><a href="http://www.domain.com/admin/item.php?id=3&action=edit">Item 3</a></li>
<li class="active"><a href="http://www.domain.com/admin/item.php?id=4&action=edit">Item 4</a></li>
<li><a href="http://www.domain.com/admin/item.php?id=5&action=edit">Item 5</a></li>
...
</ul>

How can I do it with Jquery? The most functions I tried, neither of them can get the full pathname (with all vars)

  • 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-16T17:06:03+00:00Added an answer on June 16, 2026 at 5:06 pm

    Use the attribute selector to select the anchor element with the href property set to the given path. Then use addClass to add active as the class for the selected anchor element. If you want the full current path of the page you are on, use location.href, but note that this will include the current hash too, if there is one. Also, I would suggest selecting the menu by ID, so add an ID to your nav menu.

    function setCurrentMenuPathAsActive(path){
       $(".nav li a[href='" + path + "']").addClass("active");
    }
    
    setCurrentMenuPathAsActive(location.href);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HEllo I have this URL I need to get with PHP http://www.domain.com/forum/#forum/General-discussions-0.htm The problem
For example I have a website that points to a page like this: http://www.mysite.com/folder/file
I'm trying to route a path like this: http://www.wikipediamaze.com/wiki/Washington,_D.C. The routing framework is not
So I have some path generator which now works like this http://www.openprocessing.org/visuals/?visualID=2615 (There is
I have a path like this: parent/child/reply How do I use PHP to remove
I have stored the XML path to items in a string like this: response->items->item
I have 2 domain domain1.com domain2.net i want redirect domain1.com to domain2.net with path
I have xml file like this <?xml version=1.0 encoding=UTF-8?> <specification xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=file://Desktop/normal.xsd> <university> <refstr>bdvl_te_skrm_stc</refstr>
I have magento installed in a subdirectory. www.domain.com/subdir/magento This site worked perfectly at one
The code below work like this: http://www.website.com/?page=home will pull content from http://www.website.com/home.php -- or

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.