【发布时间】:2019-10-09 19:16:11
【问题描述】:
我有一个点击功能,当点击链接时,会向下滚动到附加的 div。如何在实际向下滚动之前附加大约 5 秒的延迟?
我尝试将 .delay() 添加到函数中,但它似乎不起作用
$(".o-c").click(function() {
$('html, body').animate({
scrollTop: $(".one").offset().top
}, 2000);
});
.left {
width: 50%;
float: left;
background: red;
height: 100vh;
}
.right {
width: 50%;
float: right;
background: green;
height: 100vh;
}
.one {
width: 100%;
background: yellow;
height: 100vh;
display: block;
clear: both;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="left">
<ul class="pivot-nav">
<li class="pivot-nav-item"><a class="o-c default-underline custom-scroll-link" href="#one" data-toggle="my-scrollspy-2">1</a></li>
</ul>
</div>
<div class="one">
Some more TEXT HERE
</div>
【问题讨论】: