I have a navigation bar which I want to dynamically change the active state when in different sections of my page. I have the click change working correct and mostly the scrollspy, however I cannot work out how I can 'remove' the selection once the user scrolls to the top.
As my logo is separate from my list elements, I have got it to work with the 'clicking' (first line of js) but am having trouble relating with the scrollspy.
Basically, how can I still use the scrollspy with the logo (but not highlighting) while still relating the other items in the list?
<html>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" id="navigationbar" role="navigation">
<div class="container-fluid" id="navigationbar-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#top">LOGO HERE</a>
</div>
<!--Nav links, etc for toggling-->
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right"><!--move the active for + sr for each active-->
<li><a class="navi-link" href="#about">about. <span class="sr-only">(current)</span></a></li>
<li><a class="navi-link" href="#projects">projects.</a></li>
<li><a class="navi-link" href="#contact">contact.</a></li>
</ul>
</div><!--/.navbar-collapse -->
</div><!--/.container-fluid -->
</div>
<script type='text/javascript'>
$(document).ready(function() {
$(".navbar-brand").on("click", function(){
$(".nav").find(".active").removeClass("active");
});
$(".nav a").on("click", function(){
$(".nav").find(".active").removeClass("active");
$(this).parent().addClass("active");
});
$('body').scrollspy({ target: '.navbar' })
});
</script>
</body>
</html>