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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:34:19+00:00 2026-05-27T07:34:19+00:00

I have a website which is one page and the user navigates to each

  • 0

I have a website which is one page and the user navigates to each section using links which uses the scrollto jquery plugin.

My problem is: I want to show the active link in the main menu. So if you scroll to the contact form the contact link is highlighted. Now I could do this in jquery by adding the class after clicking. If done like that if a user was to manually scroll to another section the contact link would still be active, which would be incorrect and misleading.

So my thoughts would be to somehow work out which div id is currently in view. I don’t really understand how to do that though. Any ideas?

  • 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-27T07:34:19+00:00Added an answer on May 27, 2026 at 7:34 am

    This should work for you to add the manual scrolling override:

    $(function(){
        var sections = {},
            _height  = $(window).height(),
            i        = 0;
    
        // Grab positions of our sections 
        $('.section').each(function(){
            sections[this.name] = $(this).offset().top;
        });
    
        $(document).scroll(function(){
            var pos = $(this).scrollTop();
    
            // Look in the sections object and see if any section is viewable on the screen. 
            // If two are viewable, the lower one will be the active one. 
            for(i in sections){
                if(sections[i] > pos && sections[i] < pos + _height){
                    $('a').removeClass('active');
                    $('#nav_' + i).addClass('active');
                }  
            }
        });
    });
    

    Demo: http://jsfiddle.net/x3V6Y/

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

Sidebar

Related Questions

I have one master page which applies to all pages in this website. On
I have a website which uses jQuery and lots of mouseover / mouseout effects.
I am currently working on a one-page layout for a website. Each section of
I have developed a website using visual studio 2008. Which uses active index to
i have a website page that contains only data of which one field gives
We have a website that has a common logon page. A user chooses which
I have a website which hangs about 20 times a day for between one
One of my friend wants to have a website which calculates the distance between
I have a website which sells a product to the user (downloadable). I am
I have a website which uses Spring Security. I have realized that when I

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.