Hi i want to check the scroll position , like if its greater than 200 from top they it may generate a popup for signup

        <script>
            jQuery(document).ready(function($) {

                // hide #back-top first


                // fade in #back-top
                $(function() {
                    $(window).scroll(function() {
                        if ($(this).scrollTop() > 100) {
                alert(123);
            } else {
                alert(321);
            }
                    });
                });
            });
        </script>

i use that code , but its not generating any alert....

Recommended Answers

Well with this code, and only this code, I'm getting a bunch of popups with "123" when I scroll:

$(window).scroll(function()
{
    // Let's check the scrollTop just to be sure stuff is working:
    console.log('ScrollTop: ' + $(this).scrollTop());

    if($(this).scrollTop() > 100)
    {
        alert(123);
    }
    else
    {
        alert(321);
    }
});
Jump to Post

All 4 Replies

Hmmm I don't know but it seems kind of useless to me to put all this stuff inside a function that doesn't get executed, or does it when you pass it to jQuery? What about trying just:

$(window).scroll(function() {
    // Let's check the scrollTop just to be sure stuff is working:
    console.log('ScrollTop: ' + $(this).scrollTop());

    if ($(this).scrollTop() > 100) {
        alert(123);
    } else {
        alert(321);
    }
});

Not working for me ...

Well with this code, and only this code, I'm getting a bunch of popups with "123" when I scroll:

$(window).scroll(function()
{
    // Let's check the scrollTop just to be sure stuff is working:
    console.log('ScrollTop: ' + $(this).scrollTop());

    if($(this).scrollTop() > 100)
    {
        alert(123);
    }
    else
    {
        alert(321);
    }
});

Have you checked your Firebug to see if any other errors are occurring that may be halting the execution of your script?

thanks its working for me .. only i need to intilize with jQuery instead of $

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.