Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Total Page Scroll Control Reply To: Total Page Scroll Control

#253026
Shikkediel
Participant

when you scroll to a certain element (say #id) anchored link nav-link should become active – not done

Isn’t this the code at the bottom? Could be a bit shorter though – and you could combine it:

$(function() {
  $('.scroll').click(function(e) {
    $('.active').removeClass('active');
    $(this).addClass('active');
    var destination = $(this).attr('href');
    e.preventDefault(); //-- the hell is this e --//
    $('html, body').animate({
      scrollTop: $(destination).offset().top
    }, 750);
  });
});