How to alert when scroll page every 200px;

How to alert when scroll page every 200px;

i want to alert some text when user sceoll page every 200px; how can i do that?

i try like this but not work

$(window).scroll(function () {

    if ($(window).scrollTop()%200 != '0') {
                alert($(window).scrollTop());
    }
});

Upvotes: 0

Views: 983

Answers (1)

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

You should check like this:

if ($(window).scrollTop() % 200 == 0) {
    alert($(window).scrollTop());
}

Upvotes: 1

Related Questions