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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:07:39+00:00 2026-05-29T04:07:39+00:00

$(window).scroll(function(e){ if($(this).scrollTop()>=400) $(‘#jtop’).show(‘slow’); if($(this).scrollTop()<400) if($(‘#jtop’).width()) $(‘#jtop’).hide(‘slow’); }); I’m using the function to determine if

  • 0
$(window).scroll(function(e){
    if($(this).scrollTop()>=400)    $('#jtop').show('slow');
    if($(this).scrollTop()<400) if($('#jtop').width()) $('#jtop').hide('slow');
});

I’m using the function to determine if someone scrolls down over 400 an toggling an image and it’s working fine but when I try to get notified if someone reaches my footer’s top position it doesn’t return the expected value. I used offset().top but it alerts me when I scroll down to bottom 0. I just want to know when user is entering and leaving my footer. Hope someone will help me. Thanks in advance.
If you want to see it in action then here is the link heera.it

Non working code

    var ftop=$('#footer').offset().top;
    $(window).scroll(function(e){
        if($(this).scrollTop()>=400)
        {
            $('#jtop').show('slow');
        }
        if($(this).scrollTop()<400)
        {
            if($('#jtop').width()) $('#jtop').hide('slow');
        }
        if($(this).scrollTop()>=ftop)   console.log('true');
        if($(this).scrollTop()<ftop)    console.log('false');
    });
  • 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-29T04:07:40+00:00Added an answer on May 29, 2026 at 4:07 am

    This is just a guess, but your footer’s top position is probably being calculated correctly already, so when calculating whether or not the footer has been reached would involve calculating whether or not the scroll height and the viewport height together reach the footer’s top position.

    That make sense? If the footer’s top position is say 1000px away, the scroll height of the window together with the height of the viewport will tell if we’ve reached the footer. I’ve made the mistake of trying to equate just the scroll height value, which would only show if the footer had reached the top of the screen completely.

    So to some code:

    var footer_top = $("#footer").position().top;
    
    $(window).scroll(function(e) {
    
        var scroll_top = $(this).scrollTop();
        var viewport_height = $(this).height();
    
        if (scroll_top + viewport_height >= footer_top) {
            alert("Footer reached!");
        }
    
    });
    

    Hope this helps and makes sense!

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

Sidebar

Related Questions

I have this code. $(document).ready(function() { $('#box').hide(); $(window).bind('scroll', function(){ if($(this).scrollTop() > 200) { $(#box).fadeIn(300);
I'm using this at the moment: $(window).scroll(function() { if($(window).scrollTop() + $(window).height() == $(document).height()) {
$(window).scroll(function() { $('#myElement').css('top', $(this).scrollTop() + px); }); works great, but what if I want
http://designobvio.us/DoUs/directPro.html jQuery Script $(window).scroll(function() { $('#nav').css('top', $(this).scrollTop() + px); }); HTML <nav id=nav class=grid_2>
I'm using the $(window).scroll(); to specify a function to be call for when the
I'm using the $(window).scroll(function() to set classes on the navigation of a site. When
<script type=text/javascript> function pageLoad() { var $scrollingDiv = $(#scrollfix); $(window).scroll(function () { if ($(window).scrollTop()
normally I use this on some of my projects. //Back to top $(window).scroll(function ()
For an iPhone app I was using window.scrollBy to scroll to the bottom of
Is it possible to scroll the iframe window from the parent window using keys

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.