3

I'm having an issue when I'm using smooth scrolling and scrollspy on my website. When I click on my nav menu link I'm directed to the appropriate section. In this section I have tabs. When I click on one of the tabs the scrollbar moves up and down.

Here's my fiddle

Not sure why my JS isn't firing. Can someone assist?

Sample scrollspy code:

var $body = $(document.body); var navHeight = $('.navbar').outerHeight(true) + 80;
$body.scrollspy({
    target: '#leftCol',
    offset: navHeight
});

Sample scrolling code:

$('a[href*=#]:not([href=#])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
        var target = $(this.hash);
        target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
        if (target.length) {
            $('html,body').animate({
                scrollTop: target.offset().top - 120
            }, 1000);
            return false;
         }
     }
});
Zanon
  • 29,231
  • 20
  • 113
  • 126
Rocky
  • 73
  • 5
  • 9

0 Answers0