I want to use the scrollspy to do something it's not necessarily designed for, yet it may do the job.
I have a div #myTarget
and I simply want to detect when it scrolled to the top of the .container
and do something each time it does so.
HTML:
<div class="container" data-spy="scroll" data-target="#myTarget">
<div class="row">
<div class="col-md-12 some-content">.some content</div>
</div>
<div class="row">
<div class="col-md-12" id="myTarget">#myTarget</div>
</div>
</div>
JS:
$('body').scrollspy({
target: '#myTarget'
});
$('#myTarget').on('activate.bs.scrollspy', function () {
console.log('got to the target!');
});
Here is a jsfiddle link
P.S. I know I can use other plugins such e.g. jQuery Waypoints but I would like to stick just to Bootstrap if possible.