nowiko
nowiko

Reputation: 2557

Get current top position of document

I try output something when document scroll top will be equal to offset of some my blocks. But I didn get any results. Here is code:

$(document).ready(function () {
    if ($(document).scrollTop() === 3385) {
        console.log($('#services').offset());
    }
});

What I am doing wrong?

Upvotes: 0

Views: 300

Answers (1)

ianaya89
ianaya89

Reputation: 4233

Try this:

$(document).ready(function () {
    if ($('html').offset().top === 3385) {
        console.log($('#services').offset());
    }
});

Upvotes: 1

Related Questions