0

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....

2
Contributors
4
Replies
10
Views
3 Years
Discussion Span
Last Post by pawan768
0

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);
    }
});

Edited by minitauros

1

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?

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.