아래 코드가 작동하지 않는 이유는 누구나 알 수 있습니까? 고정 된 헤더의 높이 (여기서는 ID가 "jeden"인)를 기준으로 앵커의 대상으로 화면을 부드럽게 스크롤하기위한 것입니다. 이 기능에jQuery에서 간단한 스크롤이 작동하지 않습니다.
$(document).ready(function() {
var headerHeight, part, place;
function getOffsets() {
headerHeight = $('#jeden').height();
part = $(this).attr('href');
place = $(part).offset().top - headerHeight;
}
$(window).load(getOffsets).resize(getOffsets);
$(function() {
$('a').click(function (e) {
$('html, body').animate({
scrollTop: place
}, 'slow');
return false;
});
});
});
시도 - scrollTop :. $ (이) .offset() 상단 - $ ('#의 jeden ') .height() – Tasos