我有一个带有标记<a>
的文本,如果你点击它们,它们会带你进入下一个锚点,滚动顺畅。
有代码:
HTML
<div style="width:100%;height:1500px;background-color:black;color:white;">ciao
<div>
<a class="scrolldown" style="color:white" href="#prova">ciaoooooo</a>
</div>
</div>
<div id="prova" style="width:100%;height:1500px;background-color:silver;color:white;">ciao ancora
<div>
<a class="scrolldown" style="color:white" href="#prova2">ciaoooooo</a>
</div>
</div>
<div id="prova2" style="width:100%;height:1500px;background-color:green;color:white;">basta
</div>
的JavaScript
$(".scrolldown").click(function() {
var cane = $('this').attr("href");
$('html,body').animate({
scrollTop: $(cane).offset().top},
'slow');
});