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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:32:46+00:00 2026-05-15T03:32:46+00:00

I have a main menu: <ul class=menu> <li><a href=/><span class=l></span><span class=r></span><span class=t>Home</span></a></li> <li><a href=<%=

  • 0

I have a main menu:

<ul class="menu">
<li><a href="/"><span class="l"></span><span class="r"></span><span class="t">Home</span></a></li>
<li><a href="<%= Url.Action("Login", "User")%>"><span class="l"></span><span class="r"></span><span class="t">My Account</span></a></li>
<li><a href="#"><span class="l"></span><span class="r"></span><span class="t">Post Idea</span></a></li>
<li><a href="#"><span class="l"></span><span class="r"></span><span class="t">Browse Ideas</span></a></li>
<li><a href="#"><span class="l"></span><span class="r"></span><span class="t">Invest in Ideas</span></a></li>

And i am trying to select the active link using jQuery:

<script type="text/javascript">
    $(document).ready(function () {
        var path = location.pathname;
        var home = "/";
        $("a[href='" + [path || home] + "']").addClass("top-menuactive");
    });
</script>

However the javascript depicted above finds all links on site, not just the links in the menu.

How can i change the script to select only the links within<ul class="menu">

  • 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-15T03:32:47+00:00Added an answer on May 15, 2026 at 3:32 am

    You can use the descendant selector:

    <script type="text/javascript">
        $(document).ready(function () {
            var path = location.pathname;
            var home = "/";
            $("ul.menu a[href='" + [path || home] + "']").addClass("top-menuactive");
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this html menu: <ul id='main'> <li class='active current' id='lighty'> <a href='/'>Lighty</a> <ul>
I have an XML like: <menu> <node id=home url=url1.php> <label>Homepage</label> <node id=user url=url2.php><label>User profile</label></node>
I have a menu item Home in my main menu AND in my top
I have a NSDocument class, where I'd need to access the main menu window,
i have menu structure like below <ul class=menu_bg id=menu-main-menu> <li class=menu-item menu-item-type-post_type menu-item-object-page menu-item-653
I have the following code structure: <ul class='menu'> <li> Main Menu <ul class='hide'> <li>SubMenu1</li>
I have a main menu with an action bar. On create, I run a
I have the following simple 3 level menu structure: <nav class=main-nav class=list> <ul> <li
I have a main menu activity with a bunch of buttons. One button starts
I have a main menu window. On clicking any menu item it opens 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.