/*! * depend on Jquery */ $(function() { $(".nav-content").stick_in_parent({parent:'#stick_row', offset_top: 30}); $("a[href^='#']").on('click', function(e) { e.preventDefault(); // prevent hard jump, the default behavior scrollTo($(this)); return false; }); }); function scrollTo(obj) { var target = $(obj).attr("href"); // Set the target as variable // perform animated scrolling by getting top-position of target-element and set it as scroll target var target_load = $(target).offset().top-65; $('html, body').stop().animate({ scrollTop: target_load }, 600, function() { // location.hash = target; //attach the hash (#jumptarget) to the pageurl }); $(obj).parents("ul").find("a").removeClass("active"); $(obj).addClass("active"); return false; }