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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:07:31+00:00 2026-05-31T18:07:31+00:00

I am a little stuck. I have created almost everything in the picture below.

  • 0

I am a little stuck. I have created almost everything in the picture below. What I am stuck on is I am trying to figure out how I would set it up so that when a user clicks one of the links it makes the line below become red (after the next page loads). Obviously I would need to use Jquery to detect the page then add inline css, but what I am struggling with is I want this to be as easy as possible so that I can give this template to others and then they can add or remove items as necessary. I was trying to figure out if I could somehow use a li element to do this but I have not found a way yet. Does anyone have any ideas to help me?

enter image description here

  • 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-31T18:07:32+00:00Added an answer on May 31, 2026 at 6:07 pm

    Build your menu like this, in HTML:

    <body id='Search' >
        <div id='menu'>
            <div class='bars'></div>
            <a href='/home/' title='Home'>Home</a>
            <a href='/community/' title='Community'>Community</a>
            <a href='/search/' title='Search'>Search</a>
            <a href='/contact/' title='Contact'>Contact</a>
            <div class='bars shift'></div>            
        </div>
    </body>
    

    Note that the body tag has a page-specific id (as Cody suggests). Also note that this id must be the same as the value of the title attribute for the menu link.

    Then use this CSS:

    .bars {border-top:1px solid #CCC;border-bottom:1px solid #CCC;height:5px;}
    .shift {margin-top:-6px;}
    #menu {font-family:arial;font-size:12pt;text-align:center;}    
    #menu a {display:inline-block;padding:7px;text-decoration:none;color:#000;}
    .active {border-bottom:5px solid red;}
    

    Finally, add this jQuery to each page:

    $(document).ready(function(){
        var id = $('body').attr('id');
        $('#menu a').each(function () {
            var title = $(this).attr('title');
            $(this).removeClass('active');
            if (title == id) $(this).addClass('active');
        });
    });
    

    You can see a live fiddle demo here. (To test, just change the id of the body element and press run.)

    EDIT: The benefits of this method compared to Cody Grays’ method is that you don’t need to modify the css every time you change the HTML when you add, remove or edit a menu item. On the other hand it uses jQuery. However, if you want a pure css solution, just remove the jQuery, and the id of the body element, and instead directly apply the .active class to the particular link, depending on the particular page (similar to jackJoe’s suggestion).

    This can easily be modified if you must use <li> elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i have been stuck trying to learn this Scheme language that i heard
A little stuck here. I have a simple question I guess. Given the following
I've been stuck on a little unix command line problem. I have a website
I am a little bit stuck: I would like to change the max option
Im using Moq to create mocks of a data set. I have created a
So I have a new and exciting question that I would dearly like answered.
I have created a custom Model Binder that inherits from DefaultModelBinder, and overriding the
I have created a little robot like the Karel robot ( Wikipedia ) which
I have an Erlang application that is getting a little too resource-hungry to stay
I'm trying to learn MVC by building a full-featured website. I'm a little stuck

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.