Bootstrap scrollspy如何实现添加给定class的功能呢?

How can Bootstrap scrollspy realize the function of adding the given class?

我已经实现了scrollspy的基本功能。
导航栏具有主动效果。
但我想知道当我们在页面顶部时, 导航具有 "navbar-yellow-style" 的 class。 滚动一些像素后,导航的 class 将变为 "navbar-transparant-style" ,因此它可以变得透明。
如何用scrollspy实现?
如果没有,我该如何用其他方法实现呢?
非常感谢!

我终于明白 Bootstrap 的 Scrollspy 不是用于将给定的 class 添加到某些 div 中,而是用于激活导航部分。 要实现这个功能我可以这样编码

$(window).scroll(function(){
               if($("body").scrollTop() >= 100){
                    $("#navbar").removeClass("navbar-fixed-top");
                   console.log("suc");
               }
               if($("body").scrollTop() < 100){
                    $("#navbar").addClass("navbar-fixed-top");
               }
    })

所以我也可以检查给定标签的偏移量并实现它。
$(selector).offset().top