我有一个使用 anchor 链接进行平滑滚动的代码,但我想要的是在窗口高度上创建一个固定链接,并在页面中可用的每个部分之间跳转。我的链接显示滚动了解更多。当用户点击时,它必须转到每个部分。到目前为止我的代码是:
$("#over_scroll_text a").on('click', function(event) {
// Make sure this.hash has a value before overriding default behavior
//if (this.hash == "") {
// Prevent default anchor click behavior
event.preventDefault();
// Store hash
//var hash = this.hash;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
$('html, body').animate({
//scrollTop: $(hash).offset().top
scrollTop: $(document).height() - $(window).height()
//}, 800//, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
//window.location.hash = hash;
});
//} // End if
});
不知道我能从这里做什么。有帮助吗?
最佳答案
第 9、16 和 19 行不应被注释掉
关于javascript - 使用 anchor 链接和 jquery 在部分之间跳转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51851079/