如何在滚动的特定部分添加类

问题描述 投票:-2回答:1

嗨,我想在某个特定部分添加一个课程。模糊图像。

参考:https://www.stanford.edu/。我想在用户滚动到某个部分时模糊图像。

javascript jquery html css scroll
1个回答
0
投票

当您想要模糊图像的DIV位于页面顶部或某个特定位置时,您希望添加课程。

您必须获得DIV的动态滚动顶部(使图像模糊)。或者你可以在jQuery术语中说Offset。

    var YourDiv = $(".YourDivHavingImageToBeBlur");
    $(window).scroll(function() {
        var scroll = $(window).scrollTop();
        // Here You can add your conditions according to your requirments
        if (scroll == YourDiv.offset().top ) {
            YourDiv.addClass('YourClass');
        } 
    });
© www.soinside.com 2019 - 2024. All rights reserved.