What is better to choose the script seamless skrela?

I had a task to find a script that when you click on .contents a[href^="#"] was a smooth transition to the anchor on the page.

So I found this script, but because of him hundreds of errors and some scripts are not working.
<!-- Script smooth scroll all links, starting with # -->
the <script>
* Active menu, smooth scrolling landing page

$(window).on('scroll', scrollBlock);

var heightMenu = $('.contents a[href^="#"]').outerHeight();
var currentLink = $('.contents a[href^="#"]');
var curTarget = ";

//Set the indentation of the container
$('.page-wrap').css('padding-top', heightMenu);

//Smooth scrolling on click on element
$(currentLink).on('click', function(e){
 curTarget = $(this).attr('href');
 $('html, body').stop().animate({scrollTop: $(curTarget).offset().top - heightMenu}, 900);
 return false;

//Adds the activity menu when you scroll the document
scrollBlock function(){

 var scrollPos = $(window).scrollTop();
 curTarget = $(this).attr('href');
 var ofsetTarget = Math.round($(curTarget).offset().top - heightMenu);
 if(ofsetTarget <= scrollPos){


What better code for the smooth skrule fit?
June 10th 19 at 15:52
1 answer
June 10th 19 at 15:54
the first code is the lack of - 5a2f7c6416642660182077.png - Lucienn commented on June 10th 19 at 15:57
, outline:none tell, what kind of kindergarten - lisandro_Hills commented on June 10th 19 at 16:00
second came the script! - Lucienn commented on June 10th 19 at 16:03

Find more questions by tags JavaScript