How to make menu work for external link

2

I am using the following script to make a sliding effect between the sections of my site (links with anchors, P.E. #contact). While on my menu it 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');
});
});
});
    
asked by anonymous 19.01.2015 / 18:00

1 answer

1

Solved. It includes the class "slides" in the line:

$('body > nav .container-fluid .navbar-collapse .nav .desliza ').on("click", 'a', function(e) {

and the < li > before the link.

<li class="desliza">
    
19.01.2015 / 18:06