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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:01:03+00:00 2026-05-27T21:01:03+00:00

I am trying to scroll to the top of a specific div container. Currently

  • 0

I am trying to scroll to the top of a specific div container. Currently my code is instead scrolling the page content into view. Anybody has an idea how what’s wrong? : ) Here’s the code:

var openItem;

var showBox = function(item) {
    item.removeClass("loading");
    var infoBox = $("div.test", item);

    // Resize box
    item.width(853);
    item.height(infoBox.outerHeight());

    // Reload Masonry
    $('#container').isotope('reLayout');

    // Insert close button
    $('<a href="#" class="close">Close</a>"')
        .prependTo(".test .content")
        .click(function (e) {
            e.preventDefault();
            close(item);
        });

    // Insert close button
    $('<a href="#" class="close">Close</a>"')
        .appendTo(".test .content")
        .click(function (e) {
            e.preventDefault();
            close(item);
        });

    // Fade in test box
    setTimeout(function () {
        testBox.fadeIn();

        // Scroll box into view
        $(document).scrollTo(item, 1000);
    }, 280);
}
  • 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-27T21:01:04+00:00Added an answer on May 27, 2026 at 9:01 pm

    I believe I see your problem. Try replacing your setTimeout code with this:

    // Fade in test box
    setTimeout(function() {
        testBox.fadeIn(function() {
            // Scroll box into view
            $(document).scrollTo(item, 1000);
        });
    }, 280);
    

    The reason your original code wasn’t working before was because when $(document).scrollTo(item, 1000) was called item was not visible yet, so scrollTo didn’t know where the item was located.

    EDIT in response to comment with the code example:

    It looks like the bug you’re seeing is not by the showBox function you posted above. The problem is caused by elements with the class showMe getting hidden after the scrollTo function has been called. Try hiding the showMe elements as soon as the user clicks them instead of fading them out.

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

Sidebar

Related Questions

I am currently trying to unhide a DIV and then right after scroll down
I am trying to make the page scroll to post which has specific id
I'm trying to display top & bottom horizontal scroll bars for a div .
I'm trying to animate a boxShadow on the scroll event of my #container div.
I'm trying to scroll a textbox using the form's WndProc method. The code I've
Im trying to get infinite scroll inside of a div to work based off
I have been trying to set the scroll of my page to a certain
I am trying this code: function goToByScroll(id){ id = id.replace(link, ); $('html,body').animate({ scrollTop: $(#+id).offset().top},
Trying to make the browser scroll to a specific ID with an added offset
im trying to implement a scroll to top animation on my site http://www.cmclove.org/bootstrap but

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.