I have successfully implemented a jQuery script to change the background color of my navbar on scroll. Here's the code I used:
jQuery(document).ready(function($) {
$(window).scroll(function() {
var scrollPos = $(window).scrollTop(),
navbar = $('.acetrnt-stickynav-transparent');
if (scrollPos > 800) {
navbar.addClass('acetrnt-stickynav-color');
} else {
navbar.removeClass('acetrnt-stickynav-color');
}
});
});
However, there is one thing I'm unsure about. Is it possible for the .addClass function to trigger only after reaching a specific div, such as my container div?
You can check out the live site here: