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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:56:36+00:00 2026-05-15T02:56:36+00:00

i need some help with a menu. See the following menu: menu The code

  • 0

i need some help with a menu. See the following menu:

menu

The code for this menu:

    <div id="menu">
  <ul>
   <li class="home"><a href="#home" class="panel">home / <span class="go">you are here</span></a></li>
   <li class="about"><a href="#about" class="panel">about / <span class="go">go here</span></a></li>
   <li class="cases"><a href="#cases" class="panel">cases / <span class="go">go there</span></a></li>
   <li class="photos"><a href="#photos" class="panel">photos / <span class="go">maybe here</span></a></li>
   <li class="contact"><a href="#contact" class="panel">contact / <span class="go">or even here<span></span></a></li>
  </ul>
 </div>

What i want to do: onclick a menu item:
1. change the red text to yellow ‘you are here’
2. change the previous menu item back to its original state (eg red and “go here”).

The 4 values “go here”, “go there”, “maybe here”, “or even here” are the 4 values that should be assigned to the other menu items (like the example).

This is the code i already have:

$('#menu ul li.home').addClass('active')
$('#menu ul li.active a .go').html("you are here");

$("#menu ul li").click(function () { 
$('#menu ul li.active').removeClass('active');
     $(this).addClass('active');
     $('#menu ul li.active a .go').html("you are here");
  });

  var arr = [ "go here", "go there", "maybe here", "or even here" ];
  var obj = { item1: "go here", item2: "go there" ,item3: "maybe here", item4: "or even here"};

  $('#menu ul li').click(function () {
   var str = $('#menu ul li.active a .go').text();
   $('#menu ul li.active a .go').html(str);
  });

As you see, it’s incomplete. I don’t how to get the values from the array and assign them too a menu item. The replace text works, but not the change-back-to-original-state. Also, right now, for some reason i can’t click ONTO the list item itself in order to activate the jquery code. I need to click just a few pixels under it. But i guess that’s a css issue.

If anyone can help, i’d be super thankful!

Regards,

Mathijs

  • 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-15T02:56:37+00:00Added an answer on May 15, 2026 at 2:56 am

    This should work:

    var msgs = [ "go here", "go there", "maybe here", "or even here" ];
    var msgs_length = msgs.length;
    
    $("#menu ul li").click(function () { 
         $('#menu ul li.active').removeClass('active');
         $(this).addClass('active');
         $('.go', this).text("you are here");
    
         $("#menu ul li").not(this).each(function(i) {
             $('.go', this).text(msgs[i % msgs_length]);
         });
    });
    

    Explanation:

    • Use text() instead of .html() if you want to set text only
    • $('.go', this) will find any element with class go inside the current element (read more about selector context)
    • $("#menu ul li").not(this) selects all li elements besides the current one (read more about .not())
    • i is the index of the element in the list of the selected elements (read more about .each())
    • i % msgs_length (modulo) ensures that you always have a valid index for the message array (in case there are more menu items than messages)

    I don’t know if the color thing already works, but this is only a CSS issue:

    #menu ul li .go {
        color: #FF0;
    }
    
    #menu ul li.active .go {
        color: #F00;
    }
    

    Update:

    Btw instead of “manually” setting the value for the home list entry:

    $('#menu ul li.home').addClass('active');
    $('#menu ul li.active a .go').html("you are here");
    

    consider to simulate a click so that the values for the other list elements are correctly set:

    $('#menu li.home').click();
    

    Update2:

    To fix the “have-to-click-below” issue 😉

    $("#menu ul li a").click(function () { 
         $('#menu ul li.active').removeClass('active');
         $(this).parent().addClass('active');
         $('.go', this).text("you are here");
    
         $("#menu ul li a").not(this).each(function(i) {
             $('.go', this).text(msgs[i % msgs_length]);
         });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 457k
  • Answers 457k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Hard to tell exactly what you're asking, but if you're… May 15, 2026 at 10:56 pm
  • Editorial Team
    Editorial Team added an answer You ought to go with 307 Temporary Redirect: The requested… May 15, 2026 at 10:56 pm
  • Editorial Team
    Editorial Team added an answer If you want to map a fixed set of input… May 15, 2026 at 10:56 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.