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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:21:13+00:00 2026-05-25T03:21:13+00:00

Consider the following HTML structure for drop-down menu: <ul class=tabMenu> <li><a href=#>Games</a> <div id=sub>

  • 0

Consider the following HTML structure for drop-down menu:

<ul class="tabMenu">
    <li><a href="#">Games</a>
     <div id="sub">
        <ul>
          <li><a href="#">Main</a></li>                         
          <li><a href="#">3D</a></li>
       </ul>
     </div>
    </li>
    <li><a href="#">Videos</a>
         <div id="sub">
            <ul>
              <li><a href="#">Main</a></li>                         
              <li><a href="#">3D</a></li>
           </ul>
        </div>
    </li>
</ul>

Under this menu I write some string using Jquery(Home is the default value) which tells the user where he is:

<div class="Pointer"><a href="#">Home</a></div>

The following Jquery is used for detecting which category/subcategory is trigerred:

$('.tabMenu li a').click(function() {
            //get current link
            var currentLink = $(this);
            //get link text
            var linkText = currentLink.text();
            //Remove all activeTab classes
            $('.activeTab').removeClass('activeTab');
            //Add selected class with activeTab
            currentLink.parent().addClass("activeTab");
                    //Change pointer value according to the click
            $('.Pointer a').html(linkText);
        });

The Jquery function should return string which looks like Videos->Main if the user clicks subcategory ‘Main’ from the drop-down on ‘Videos’ and Games->Main if the user chooses Main from Games. This code gives only Main no matter if it was clicked from ‘Games’ or ‘Videos’ Any help will be greatly appreciated.

  • 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-25T03:21:13+00:00Added an answer on May 25, 2026 at 3:21 am

    You can use jQuery closest which get the first ancestor element that matches the selector, beginning at the current element and progressing up through the DOM tree.

    Working demo

    $('.tabMenu li a').click(function() {
                //get current link
                var currentLink = $(this);
                //get link text
                var linkText = currentLink.text();
    
                //Remove all activeTab classes
                $('.activeTab').removeClass('activeTab');
                //Add selected class with activeTab
                currentLink.parent().addClass("activeTab");
                        //Change pointer value according to the click
                linkText = currentLink.closest('div').closest("li").children("a").text() + " > " + linkText ;
                $('.Pointer a').html(linkText);
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following HTML: <div class=foo id=obj> I should be changed red <div class=bar
Here's my problem: Consider the following html: <div id=item1 class=green_large> <div id=item2 class=green_large> <div
Consider the following html code: <div id='x'><div id='y'>Y content</div>X content</div> I'd like to extract
Consider the following code : HTML: <div> <label for='name'>Name:</label> <input type='text' id='name' /> </div>
Consider following example : public class SomeBusinessLayerService : DataService<MyEntityContainer> { [WebInvoke] void DoSomething(string someParam)
Consider following class class test { public: test(int x){ cout<< test \n; } };
Consider the following directory structure: ROOT ------ images ............... logo.png ------ includes ............... vars.php
Let's consider following html code: <p> Some text followed by <span>a span element</span> and
Consider the following HTML. If I have a JSON reference to the <button> element,
Consider the following html page, which can load in many large png files: <html>

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.