2016-06-14 2 views
0
$('a[href="#two"]').click(function(e) { 
     e.preventDefault(); 
     var targetOffset = $('div[id="two"]').offset().top; 
     $('body').animate(
      {scrollTop: targetOffset}, 
      1000 
      ); 
    }); 

div 앵커로 부드럽게 스크롤되는 코드가 있습니다. IE (11)에서는 작동하지 않습니다. Chrome/Firefox에서 올바르게 작동합니다. 누군가 나를 도울 수 있습니까? DjQuery가 IE에서 작동하지 않는 앵커 스크립트에 애니메이션 적용

+0

당신이를 보았다 : http://stackoverflow.com/questions/29153607/jquery-scrolltop-not-working-in-ie11 – vijayP

답변

0

이것은 작동하는 것 같습니다.

$(function() { 
    $('a[href*="#"]:not([href="#"])').click(function() { 
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { 
     var target = $(this.hash); 
     target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); 
     if (target.length) { 
     $('html, body').animate({ 
      scrollTop: target.offset().top 
     }, 1000); 
     return false; 
     } 
    } 
    }); 
}); 
관련 문제