andreasjhagen
7/2/2017 - 6:14 PM

Change navigation background to transparent when scrolling past a specific anchor. Change "startchange" to the anchor. Navbar should be name

Change navigation background to transparent when scrolling past a specific anchor. Change "startchange" to the anchor. Navbar should be named "navbar-default"

// JavaScript Document

$(document).ready(function(){
	"use strict";
	
   var scroll_start = 0;
   var startchange = $('#startchange');
   var offset = startchange.offset();
   
   
    if (startchange.length){
   $(document).scroll(function() { 
      scroll_start = $(this).scrollTop();
      if(scroll_start > offset.top) {
          $(".navbar-default").css('background-color', '#f0f0f0');
       } else {
          $('.navbar-default').css('background-color', 'transparent');
       }
   });
    }
});