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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:07:24+00:00 2026-05-12T15:07:24+00:00

I want to set another class for the clicked menu-part. Clicking generates url with

  • 0

I want to set another class for the clicked menu-part. Clicking generates url with #NAME. Here is my menu:

    <div id="head_menu">
        <a href="#order"><div name="order" id="menu_part">make order</div></a>
        <a href="#portfolio"><div id="menu_part">portfolio</div></a>
        <a href="#contacts"><div id="menu_part">contacts</div></a>
        <a href="#vacancies"><div id="menu_part">vacancies</div></a>
        <a href="#about"><div id="menu_part">about company</div></a>
    </div>

I need to add class: ‘menu_choosed’ for clicked part. Here is my jquery-code:

$(document).ready(
    function()
    {
        currentPage = window.location.hash;
        $('#head_menu>div').each(
            function()
            {
                if( currentPage == $(this).hash )
                {
                    $(this).addClass("menu_choosed");
                }
            }
        )
    }
)

I really don’t know, how to filter values 🙁 Help, please.

  • 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-12T15:07:25+00:00Added an answer on May 12, 2026 at 3:07 pm

    The easy way:

    $(document).ready(
        function()
        {
            currentPage = window.location.hash;
    
            $('#head_menu a[href=' + currentPage + '] div').addClass('menu_choosed');
        }
    );
    

    There are a few problems with your HTML I would like to mention:

    • Nowadays, most people use lists (<ul>, mostly) for navigation.
    • Having a <div> inside an <a> is invalid if the <div> has display: block (default) and the <a> has display: inline (default).
    • One document may only have one element per ID. You currently have several elements with the menu_part id.
    • Using name for anchor points is not recommended. Prefer using ID’s.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<div id=example> <div id=test></div> </div> <div id=another>Blah</div> I want to set $('#another').hide() but only
I've 3 tabs. I want to set tab1 active and set another tabs passive.
I want to create a method ( set ) that injects arguments into another
i want set class for repeater when doPostBack for those dataID i wan but
I set a value in one class and then I want to retrieve that
I want to pass Value from Constructor in my Main Class to another Class.
I want to be able to refresh a view from another class, but nothing
I have a balloonGameViewController.h and another class I made called balloon.h I want to
I have set of classes. Each class is inherited from another class. The relationship
I have a class that I want to use to store properties for another

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.