I have a breadcrumb's text and link that needs to be updated when an anchor on this very long page is reached.
Example:
<div class="crumbs hidden-xs">
<a href="#">Parent link</a> / <a href="#summary" class="link-location">Summary</a>
</div>
Example of anchor far down on the page:
<h1 id="chapter-2" class="page-location">Chapter 2 title here</h1>
When the above anchor is at the top of the screen, I need:
<a href="#summary" class="link-location">Summary</a>
to change to:
<a href="#chapter-2" class="link-location">Chapter 2 title here</a>
and when I am all the way back at the top of the page there should be no breadcrumb:
<div class="crumbs hidden-xs">
<a href="#">Parent link</a>
</div>
I have tried a number of things and I'm a bit puzzled. This lead to me getting the menu to work:
$("#main-nav .panel a").on("click", function() {
$('.link-location').html( $(this).html() );
});`
I have also tried the following:
var t = $(".page-location").offset().top;
$(document).scroll(function(){
if($(this).scrollTop() > t)
{
$('.link-location').html( $(this).html() );
}
});
This doesn't seem to do anything for me.
You can find an example of my layout here: http://jsfiddle.net/15298c0p/
Any help would be greatly appreciated.