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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:43:18+00:00 2026-06-14T02:43:18+00:00

I am trying to animate a div element to slide offscreen at browser window

  • 0

I am trying to animate a div element to slide offscreen at browser window top after a user clicks on a link. This link appears when a user scrolls the page down past a certain point. When the div is clicked, the browser window animates and scrolls to the top of the page as the “Back to top” div fades out. I am needing to make this “Back to top” div not only fade out, but also slide to the top of the browser window offscreen as it’s fading out. Here’s what I have thus far:

Javascript:

$(function(){
    $("#back-to-top").hide();

    $(function() {
        $(window).scroll(function() {
            if($(this).scrollTop() > 100) {
                $('#back-to-top').fadeIn('slow');
            } else {
                $('#back-to-top').fadeOut('slow');
            }
        });

        $('a#back-to-top').click(function() {
            $('body,html').animate({
                scrollTop: 0
            }, 800);
            return false;

            $('#back-to-top').animate({  // The part that doesn't work
                margin: '-800px 0 0 0'
                // top: '-800px' 
            });
        });
    });
});
  • 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-14T02:43:19+00:00Added an answer on June 14, 2026 at 2:43 am

    I think the problem can be with the return false

     $('a#back-to-top').click(function() {
                $(this).animate({ bottom: '1000px', opacity: 0 }, 2000, function(){
                    $('a#back-to-top').hide(function(){
                        $(this).css({ bottom: '40px', opacity: 1 });
                    });
                });
                $('body,html').animate({
                    scrollTop: 0
                }, 1500);
                return false;
            });
    

    I updated the code. It works perfectly what you are asking for. You need to restore the link’s position and opacity, once the animation completes.

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

Sidebar

Related Questions

I am trying this code: function goToByScroll(id){ id = id.replace(link, ); $('html,body').animate({ scrollTop: $(#+id).offset().top},
I'm trying to animate a logo. The markup looks like this: <div id=logo> <h1>
I have a div element, that on click event, a link slides in. This
I'm trying to animate the backgroundPositionY of an <div> element. What I try to
I'm trying to animate the div within an list item with a click event
I am trying to animate a div moving 200px horizontally in JavaScript. The code
I am trying to find a way to animate a div using jQuery to
I am trying to animate sliding out one view from a window and simultaneous
I'm trying to animate drop up using negative top, the animation went okay, but
I am trying to show the element using the blind animation: <div onclick=$('#animatable').show('blind', null,

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.