Javascript – Window Scroll Function Not Working

htmljavascriptjquery

I was making a blog, and tried to use $(window).scroll(function(), but something prevents it from working.

I try to add class named scrolled to body when user scrolls down. Any idea which would prevent it working properly? Console doesn't give any error regarding to this.

JS

$(document).ready(function($) {
    $(window).scroll(function() {    
        var scroll = $(window).scrollTop();

        if (scroll >= 100) {
            $("body").addClass("scrolled");
        } else {
            $("body").removeClass("scrolled");
        }
    });
});

LIVE PREVIEW

http://personaii-demo.tumblr.com/

Best Solution

Remove overflow:auto property added to the container. This will work.