T
T
tokmaganbet12018-03-16 12:12:56
JavaScript
tokmaganbet1, 2018-03-16 12:12:56

Scroll question?

Hello everyone, how can I track the scroll of a page 300px from its start using js / jquery?
The code below didn't work.

$("body").ready(function($){
    var height = "300px";
    if ($("body").scrollTop >= height ({
        $("body").addClass("MyClass");
    } else {
        $("body").removeClass("MyClass");
    });
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mShpakov, 2018-03-16
@mShpakov

https://api.jquery.com/scroll/
With the help of this event (I guess)

M
maxsnw, 2018-03-16
@maxsnw

so hang up the windows scroll handler, but don't need a body-ready)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question