2017-10-16 21 views
0

내 웹 사이트 http://www.dicosoftware.com에서 스크롤을 구현하여 사이트의 각 섹션을 부드럽게 스크롤하려고하지만 작동하지 않습니다. 확인을 위해 사이트로 이동하면 제공 할 수있는 모든 의견을 크게 환영합니다.jQuery scroll to div onclick 작동하지 않음

main.js 파일에서 다음 jQuery 함수를 사용하고 있습니다.

$(".js--scroll-to-main").click(function(){ 
    $('html,body').animate({scrollTop:$("#header").offset().top},2000); 
}); 

$(".js--scroll-to-about_us").click(function({ 
    $('html,body').animate({scrollTop:$("#sectionabout_us").offset().top},2000; 
}); 

$(".js--scroll-to-services").click(function(){ 
     $('html, body').animate({scrollTop:$("#section-services").offset().top},2000); 
}); 

$(".js--scroll-to-contact_us").click(function(){ 
     $('html, body').animate({scrollTop:$("#section-contact_us").offset().top},2000); 
}); 

내 링크가 정렬되지 않은 목록

<ul class="main-nav hidden js--main-nav"> 
    <li> <a class="js--scroll-to-main" href="#">Inicio</a> </li> 
    <li> <a class="js--scroll-to-about_us" href="#">Nosotros</a> </li> 
    <li> <a class="js--scroll-to-services" href="#">Servicios</a> </li> 
    <li class="contact-link"> <a class="js--scroll-to-contact_us" href="#">Contactanos</a> </li> 
</ul> 

에서 설정하고 각 섹션은 다음 div의 아래 설정입니다.

<header id="header"> ... </header> 
<section class="section-about_us js--section-about_us" id="section-about_us"> ... </section> 
<section class="section-services js--section-services" id="section-services"> ... </section> 
<section class="section-contact js--section-contact" id="section-contact_us"> ... </section> 

답변

1

주 콘솔에서 오류 : 비슷한 question에서

TypeError: $('html, body').animate is not a function.

그것은 jQuery를의 슬림 빌드가 많은 기능을 포함하지 않음을 지적했다.

당신은 jQuery를의 전체 버전에 아래의 스크립트를 변경해야합니다 :

<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>

같은 :

https://code.jquery.com/jquery-3.1.1.min.js