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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:31:41+00:00 2026-05-15T17:31:41+00:00

I have a page that has three divs one at the top, one at

  • 0

I have a page that has three divs one at the top, one at the side, and one content div in the bottom left. The content div contains a series of divs. and I want a button that allows you to step through them highlighting them one at a time. However, the content div contains more data than can fit on a screen, and so I put it in an overflow: scroll. Now I need to ensure that the highlighted div in the content is visible as the user clicks through.

I have tried various techniques recommended here and other web sites, but they all scroll the page not the content div, meaning my header and side bar scroll out of view. Can anyone give me some pointers on how to scroll just the overflow div. Here is some simplified sample code of what I am doing.

First the HTML:

    <div id='header'>
        Header
        <input type="button" id="NextButton" value="Next" />
    </div>
    <div id='content' style="overflow: scroll">
        <div id="div1" class='highlight'> Text for div1 </div>
        <div id="div2"> Text for div2 </div>
        <div id="div3"> Text for div3 </div>
        <div id="div4"> Text for div4 </div>
        <div id="div5"> Text for div5 </div>
    </div>
</div>
<div id='sidebar' style="float:right">
    Sidebar
</div>

Now the JavaScript (Note obviously it is using jQuery)

    var current;
    $(document).ready(function () {
        var current = $('#div1');
        $('#NextButton').click(function() {
            current.removeClass('highlight');
            current = current.next();
            current.addClass('highlight');
          // Somehow make content scroll to the top of the div#content  
        })
    });

FWIW, here is the style element:

    .highlight { color: Red; }

As you see the click on the #NextButton moves through the divs changing the highlight, however, I also need to ensure that div is actually visible, such as by scrolling it to the top. (BTW, I know that it doesn’t check for the end, I am just stripping it down to the minimum for simplicity.)

Any help would be appreciated.

  • 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-15T17:31:42+00:00Added an answer on May 15, 2026 at 5:31 pm

    The jQuery plugin ScrollTo works on individual elements. The trouble is knowing if an element is shown or not. Depending on browser compatibility this may not always be possible. You can ‘cheat’ by always scrolling, however this can seem a bit jittery for users.

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

Sidebar

Related Questions

I have a page that has about 20 divs one under the other on
i have a page that has sections as divs with inner divs and content.
I have an ASP.NET page that has three div s within the only form
When I have three divs that all have float left I want the sections
I have a simple script that should cause one of three divs to be
I have a page which has DIVs which contain short phrases (one-two words) of
So I have two div elements on my page, one directly on top of
The Setup: I have a page written in JS that has 3 main divs:
Okay, I have a page on a Drupal install that has multiple divs. I
I have a page that has a left menu in it. This left menu

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.