나는이 사이트에서 멋진 부드러운 스크롤을 얻기 위해 jQuery를 약간 작성하는 방법에 대한 지침서를 따라 갔다. 여기에 당신을위한 혀가있어 참조 : https://www.youtube.com/watch?v=S6pzabpUmocjQuery 부드러운 스크롤 문제
그러나 내 JQ 코드 어딘가에 문제가있는 것 같습니다. 애니메이션이 작동하지 않습니다 ... 볼 수있는 새로운 눈을 가지고있는 것이 좋을 것입니다. 나는 잘못 가고 그것을 고치는 방법.
이 순간 현재 콘솔 내가이 문제를 여기에 TypeError: Cannot read property 'top' of undefined
에게이 내게 말하고 내 현재 빌드 여기 http://kapena.github.io/pp_web/#services-pp
은 내가 JQ 코드
$(function() {
// catch all clicks on page
$('a').click(function() {
// check if has hash
if(this.hash) {
// get rid of the # sign
var hash = this.hash.substr(1);
//get the position of the <a name>
var $toElement = $("a[name="+hash+"]");
var toPosition = $toElement.position().top;
// scroll/animate that element
$ ('body,html').animate({
scrollTop : toPosition
},2000,"easeOutExpo");
// don't do the jump
return false;
}
});
if(location.hash) {
var hash = location.hash
window.scroll(0,0);
$('a[href='+hash+"]").click();
}
});
콘솔에 var 해시를 기록하고 여기에 –
을 추가하면 HTML도 추가 할 수 있습니까? –