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

  • Home
  • SEARCH
  • 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 7598373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:23:30+00:00 2026-05-30T22:23:30+00:00

I have set the sessions into rows. <div class=container id=session1> <div class=row session> <div

  • 0

I have set the sessions into rows.

<div class="container" id="session1">
  <div class="row session">
    <div class="fourcol">
        <h2>Session 3:</h2>
    </div>

     <div class="fourcol last">
         <p> Information about session </p>
    </div>

  </div>
</div>

I have many of these sessions and need a way to highlight that you are reading session 1. I would like to add a .selected class to <h2 class="selected">Session 3:</h2> as you scroll past it.

I’m hoping this will also add the .selected class if there are any incoming anchor links. to /sessions#session1 because it would have to ‘scroll’ to that position

Any help would be great. Thanks.

  • 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-30T22:23:32+00:00Added an answer on May 30, 2026 at 10:23 pm

    I would recommend a look at jQuery Waypoints, it’s got exactly what you’re looking for, and it’s easy to use.

    Here’s an example I made, where I add the .selected class when an element is scrolled into the viewport using jQuery Waypoints.


    You can of course do it yourself as well, but you’d be doing the same thing Waypoint is already doing.
    First use the .scroll event on either document or a desired element to capture particular event you want.

    $(document).scroll(function(e){
    });
    

    Then use .scrollTop to check where you are, and add “boundaries” your elements have to be within, based on the viewport, ie, the window.

    $(document).scroll(function(e){
        var bound_top = $(this).scrollTop(),
            bound_bottom = bound_top + $(window).height();
    });
    

    Then check each header/section element to see if they are within those boundaries

    $(document).scroll(function(e){
        var bound_top = $(this).scrollTop(),
            bound_bottom = bound_top + $(window).height();
    
        $("h2").each(function(){
            if( 
                $(this).position().top >= bound_top &&
                $(this).position().top + $(this).outerHeight() <= bound_bottom
            ){
                $(this).addClass("selected");
            }else{
                $(this).removeClass("selected");
            }
        }
    });
    

    It would look a little something like in this example I made.

    This approach lets you do things exactly the way you want them.
    jQuery Waypoints is a good and fast alternative.

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

Sidebar

Related Questions

I am currently in C# and I have set Session variables on each page.
I am trying to set Session values using a IHttpModule. I have set the
I have set the FlushMode property on an NHibernate session to FlushMode.Never, but when
I have tried the obvious SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED, but my
I recently discovered that when you have a page set to session readonly and
I have problem with cakephp's Session->write method. If I set a value like $_SESSION['..']
We have set up a system where notifications get sent to a user with
I have set a canvas' background to an image of a company logo. I
I have set up transactional replication between two SQL Servers on different ends of
I have set up a version control system using TortoiseSVN at my home to

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.