简体   繁体   中英

jQuery Waypoints Navbar In Bootstrap

I'm creating a website with Bootstrap, and I'm trying to make the navbar change transparency when it is past the header and reaches the main content, but I just can't seem to get it to do anything.

There aren't many tutorials on Waypoints for some reason so I'm not even sure I'm using it right in the first place.

For the main content I've created a Div with a class "test"

Here's the JS:

var $navbar = $('test');

$navbar.waypoint(function () {
    $navbar.addClass('.js-navbar-animate');
});

CSS I'm using is quite simply:

.navbar{
    opacity: 0.5;
}

.js-navbar-animate{
    opacity: 1;
}

First, is that normal that for looking for your .test element you wrote:

var $navbar = $('test');

Instead of:

var $navbar = $('.test');

?

Also, I bet you're looking for that functionality from Waypoint .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM