当用户点击此箭头时,它将转到下一部分,然后单击它将转到下一部分。每次用户点击向下箭头时,在短序列部分滚动
这是我的HTML
<section id="intro">
</section>
<section id="about-us">
</section>
<section id="services">
</section>
<section id="team">
</section>
<section id="contact">
</section>
非常感谢提前
答案 0 :(得分:0)
jQuery.fn.extend({
scrollTo : function(speed, easing) {
return this.each(function() {
var targetOffset = $(this).offset().top;
$('html,body').animate({scrollTop: targetOffset}, speed, easing);
});
}
});
// Scroll to "about" section
$('#about').scrollTo('fast', 'linear');
<强> JQUERY:强>
$('.next-section').click(function(){
var $this = $(this),
$next = $this.parent().next();
$next.scrollTo($next.offset().top, 500, 'linear');
});
$('.prev-section').click(function(){
var $this = $(this),
$prev = $this.parent().prev();
$prev.scrollTo($prev.offset().top, 500, 'linear');
});
<强> HTML 强>
<section id="about">
<a href="#" class="prev-section">Previous Section</a>
<a href="#" class="next-section">Next Section</a>
<div class="section-content">
Foobar
</div>
</section>
原帖: