안녕하세요 저는 클릭 한 후에 요소로 페이지를 스크롤하는 코드를 작성했지만 부드러운 스크롤을하기 전에 페이지의 맨 위로 이동합니다. 누군가 내가 잘못하고있는 것을 설명 할 수 있습니까? jQuery - div 로의 부드러운 스크롤
이
스크립트$('a[href*="#"]').click(function(e){
e.preventDefault();
if($(this).attr('href') == '#') {
$('html, body').animate({
scrollTop: $('body').offset().top
}, 1000);
window.location.hash = '';
} else {
$('html, body').animate({
scrollTop: $($.attr(this, 'href')).offset().top - $(this).height()
}, 1000);
window.location.hash = $(this).attr('href');
}
return false;
});
내가 JS를 배울 수있는 곳 말해입니다 :)
학습을위한 링크와 Masterin을 따라 가세요. g JS : http://stackoverflow.com/questions/2687566/learning-javascript-in-one-weekend http://stackoverflow.com/questions/11246/best-resources-to-learn-javascript –
이 줄을 window.location.hash = '''에 두는 이유는 무엇입니까? 이 줄을 써 보지 않으셨습니까? – anu
예 그것의 많은 구성을 tryed했지만 여전히 파이어 폭스에서 "점프"합니다. – arclite