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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:44:01+00:00 2026-06-16T18:44:01+00:00

http://jsfiddle.net/motocomdigital/gUWdJ/ I’m after a jquery scroll technique please that I would like to adapt

  • 0

http://jsfiddle.net/motocomdigital/gUWdJ/

I’m after a jquery scroll technique please that I would like to adapt to my project.

Please see my project example as a fiddle here http://jsfiddle.net/motocomdigital/gUWdJ/

Currently you can see that my nav links automatically animates the scrolling relative to the <section>‘s.

My question is, using the $(window).scroll method, how can I add a .active class to my nav a when the sections reach the top of the window?

So for example if the user scrolls down the page (instead of the navigation links), I want the active class to be added relative navigation link. Indicating where you are on the page.

The active class will have to be removed then added every time I’m guessing as the user scrolls down the page.

Also you will have to account for the 28px height of the fixed navigation bar, offset top window.

Can anyone please show me a technique that I can try and use or adapt, or perhaps show me using my jsfiddle 🙂

Any help would be much appreciated, thanks in advance!

http://jsfiddle.net/motocomdigital/gUWdJ/

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-06-16T18:44:02+00:00Added an answer on June 16, 2026 at 6:44 pm

    If you wish a more generic function:

    SEE DEMO

    $(window).scroll(function() {
        var windscroll = $(window).scrollTop();
        if (windscroll >= 100) {
            $('nav').addClass('fixed');
            $('.wrapper section').each(function(i) {
                if ($(this).position().top <= windscroll - 100) {
                    $('nav a.active').removeClass('active');
                    $('nav a').eq(i).addClass('active');
                }
            });
    
        } else {
    
            $('nav').removeClass('fixed');
            $('nav a.active').removeClass('active');
            $('nav a:first').addClass('active');
        }
    
    }).scroll();​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://jsfiddle.net/tgWKZ/ This worked in the older version of jQuery. Only thing that is stopping
Please see my jsfiddle i've created to replicate my problem. http://jsfiddle.net/motocomdigital/22KFS/3/ In my project,
http://jsfiddle.net/nwT6v/1/ That's my script basically. How come? I want to add text after clicking
http://jsfiddle.net/JamesKyle/y7hBQ/ I'm making a simple jquery counting function that adds the following classes: First
I've created a fiddle to demonstrate my issue: http://jsfiddle.net/motocomdigital/QyhpX/5/ OVERVIEW I'm creating a tabbed
http://jsfiddle.net/ww7dN/ I'm trying to design a page that is split in 2 colors all
http://jsfiddle.net/maximus392/gcQmM/7/ My problem is that the resizable image is making the other image to
http://jsfiddle.net/gUckp/ In the above demo, I'd like to show an orange round image BELOW
http://jsfiddle.net/motocomdigital/c8Mey/1/ I'm using a twitter script which i'm binding a function to get the
http://jsfiddle.net/motocomdigital/dKDJz/6/ I'm trying to fix position a div to top 50% off my window

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.