2
I am using the following script to make a sliding effect between sections of my site (anchored links. P.E. #contact). However my menu has an external link, how do I make it work?
$(function() {
var navH = $('body > .nav').outerHeight(true);
$('body').css({
"margin-top": navH + "px"
});
$('body > nav .container-fluid .navbar-collapse .nav ').on("click", 'a', function(e) {
e.preventDefault();
var target = $(this).attr("href"),
elementOffset = $(target).offset().top,
distance = (elementOffset - navH);
$("html, body").stop(true, true).animate({
scrollTop: distance
}, '500', 'swing', function() {
$('body > .nav .active').removeClass("active");
$('a[href="' + target + '"]').parent().addClass('active');
});
});
});