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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:31:27+00:00 2026-06-16T00:31:27+00:00

The $(element).scroll(function(){}); function isn’t working for me when I put it into a js

  • 0

The $(element).scroll(function(){}); function isn’t working for me when I put it into a js file but when I enter it into the console (just the scroll func), it works just fine.

I’m trying to do a scrolling pagination.

I’ve looked through my other js files and the only thing that I think could be conflicting is another one of the files has a $(document).ready(function(){}) but I’m pretty sure that’s not the problem. I’m also using Dropkick to make pretty dropdowns but I doubt that’s it either.

Here’s the code, almost verbatim. It’s basic for now until I can figure out how to get it to load.

$('#main').scroll(function(){
    if(($('#main').prop('scrollHeight'))==
        ($('#main').scrollTop()+$(document).height()-10)){
        //^there's a strange 10px empty space that needs to be accounted for
        $('#loading').show();
        $('#main').css('overflow','hidden');
        addMore();
    }
});
$(document).ready(function(){
    addMore();
});
addmore.counter=0;
function addMore(){
    $.ajax({
    async: 'true',
    url: 'http://mywebsite.com/bc/get',
    type: 'post',
    data: ({'offset':(addmore.counter)}),
    success: function(data) {
        $('#scrollingpagination').append(data);
        $('#loading').hide();
        $('#main').css('overflow','scroll');
        addmore.counter++;
    }
    });
}

And here’s the HTML (not verbatim, but same idea)

<!--I'm only including the "main" div that shows the content.-->
<div id='main'>
    <div id='scrollingpagination'></div>
    <div id='loading'></div>
</div>

Thanks guys, I really appreciate it!

  • 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-16T00:31:28+00:00Added an answer on June 16, 2026 at 12:31 am

    try keeping

    $('#main').scroll(function(){
                ......
    }) 
    

    inside document.ready. i think it was called before the dom was ready

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

Sidebar

Related Questions

I'm using the jQuery .scroll() function to make a certain element fade to 0.2
$(document).scroll(function() { var distanceLeft = $(document).scrollLeft(); if( distanceLeft > 7200) { $('#element').animate({height: 421, top:
i have a function to reverse my scroll bar function using an custom element.
Using this script: <script> $(function() { $(window).scroll(function(){ $('#Your element id').slideUp('slow'); }); }); </script> Is
i have a working script, that allows me to scroll inside a -element, while
I am working on a script that will scroll through list elements by clicking
So I have an element that toggles between two background colours when clicked. But
actually i downloaded code for scroll from....... http://sorgalla.com/jcarousel/ but when i added it in
I'm trying to hack together an infinite scroll system for a site, but am
I have to make an iframe element from java script so it isn't scrollable

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.